{"id":326,"date":"2017-01-12T11:16:26","date_gmt":"2017-01-12T03:16:26","guid":{"rendered":"http:\/\/kylelv.com\/?p=326"},"modified":"2017-12-22T20:08:23","modified_gmt":"2017-12-22T12:08:23","slug":"bzoj-1430-%e5%b0%8f%e7%8c%b4%e6%89%93%e6%9e%b6-prufer%e7%bc%96%e7%a0%81","status":"publish","type":"post","link":"https:\/\/blog.kylelv.com\/?p=326","title":{"rendered":"bzoj 1430: \u5c0f\u7334\u6253\u67b6  &#8212; prufer\u7f16\u7801"},"content":{"rendered":"<p><center><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_73 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69fdef75bf60c\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69fdef75bf60c\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/blog.kylelv.com\/?p=326\/#1430_%E5%B0%8F%E7%8C%B4%E6%89%93%E6%9E%B6\" title=\"1430: \u5c0f\u7334\u6253\u67b6\">1430: \u5c0f\u7334\u6253\u67b6<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/blog.kylelv.com\/?p=326\/#Description\" title=\"Description\">Description<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/blog.kylelv.com\/?p=326\/#Input\" title=\"Input\">Input<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/blog.kylelv.com\/?p=326\/#Output\" title=\"Output\">Output<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/blog.kylelv.com\/?p=326\/#Sample_Input\" title=\"Sample Input\">Sample Input<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/blog.kylelv.com\/?p=326\/#Sample_Output\" title=\"Sample Output\">Sample Output<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/blog.kylelv.com\/?p=326\/#HINT\" title=\"HINT\">HINT<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/blog.kylelv.com\/?p=326\/#Source\" title=\"Source\">Source<\/a><\/li><\/ul><\/nav><\/div>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"1430_%E5%B0%8F%E7%8C%B4%E6%89%93%E6%9E%B6\"><\/span>1430: \u5c0f\u7334\u6253\u67b6<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span class=\"green\">Time Limit:\u00a05 Sec\u00a0\u00a0Memory Limit:\u00a0162 MB<\/span><\/center><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Description\"><\/span>Description<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\u4e00\u5f00\u59cb\u68ee\u6797\u91cc\u9762\u6709N\u53ea\u4e92\u4e0d\u76f8\u8bc6\u7684\u5c0f\u7334\u5b50\uff0c\u5b83\u4eec\u7ecf\u5e38\u6253\u67b6\uff0c\u4f46\u6253\u67b6\u7684\u53cc\u65b9\u90fd\u5fc5\u987b\u4e0d\u662f\u597d\u670b\u53cb\u3002\u6bcf\u6b21\u6253\u5b8c\u67b6\u540e\uff0c\u6253\u67b6\u7684\u53cc\u65b9\u4ee5\u53ca\u5b83\u4eec\u7684\u597d\u670b\u53cb\u5c31\u4f1a\u4e92\u76f8\u8ba4\u8bc6\uff0c\u6210\u4e3a\u597d\u670b\u53cb\u3002\u7ecf\u8fc7N-1\u6b21\u6253\u67b6\u4e4b\u540e\uff0c\u6574\u4e2a\u68ee\u6797\u7684\u5c0f\u7334\u90fd\u4f1a\u6210\u4e3a\u597d\u670b\u53cb\u3002 \u73b0\u5728\u7684\u95ee\u9898\u662f\uff0c\u603b\u5171\u6709\u591a\u5c11\u79cd\u4e0d\u540c\u7684\u6253\u67b6\u8fc7\u7a0b\u3002 \u6bd4\u5982\u5f53N=3\u65f6\uff0c\u5c31\u6709{1-2,1-3}{1-2,2-3}{1-3,1-2}{1-3,2-3}{2-3,1-2}{2-3,1-3}\u516d\u79cd\u4e0d\u540c\u7684\u6253\u67b6\u8fc7\u7a0b\u3002<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Input\"><\/span>Input<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\u4e00\u4e2a\u6574\u6570N\u3002<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Output\"><\/span>Output<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\u4e00\u884c\uff0c\u65b9\u6848\u6570mod 9999991\u3002<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Sample_Input\"><\/span>Sample Input<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\"><span class=\"sampledata\">4<br \/>\n<\/span><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Sample_Output\"><\/span>Sample Output<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\"><span class=\"sampledata\">96<\/p>\n<p><\/span><\/div>\n<h2><span class=\"ez-toc-section\" id=\"HINT\"><\/span>HINT<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<p>50%\u7684\u6570\u636eN&lt;=10^3\u3002<br \/>\n100%\u7684\u6570\u636eN&lt;=10^6\u3002<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Source\"><\/span>Source<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<pre class=\"lang:c++ decode:true \">#include&lt;cstdio&gt;\r\n#define mod 9999991\r\n#define ll long long\r\nll ksm(ll a,ll b)\r\n{\r\n    ll c=1;\r\n    while(b){\r\n        if(b&amp;1) c=c*a%mod;\r\n        a=a*a%mod;b&gt;&gt;=1;\r\n    }\r\n    return c%mod;\r\n}\r\nll n,ans;\r\nint main()\r\n{\r\n    scanf(\"%lld\",&amp;n);\r\n    ans=ksm(n,n-2);\r\n    for(int i=1;i&lt;n;i++) ans=(ans*i)%mod;\r\n    printf(\"%lld\",ans);\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1430: \u5c0f\u7334\u6253\u67b6 Time Limit:\u00a05 Sec\u00a0\u00a0Memory Limit:\u00a0162 MB Desc [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[24],"class_list":["post-326","post","type-post","status-publish","format-standard","hentry","category-bzoj","tag-prufer"],"_links":{"self":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/326","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=326"}],"version-history":[{"count":1,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/326\/revisions"}],"predecessor-version":[{"id":327,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/326\/revisions\/327"}],"wp:attachment":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}