{"id":384,"date":"2017-03-10T15:51:38","date_gmt":"2017-03-10T07:51:38","guid":{"rendered":"http:\/\/kylelv.com\/?p=384"},"modified":"2017-12-28T14:50:52","modified_gmt":"2017-12-28T06:50:52","slug":"bzoj-4766-%e6%96%87%e8%89%ba%e8%ae%a1%e7%ae%97%e5%a7%ac-%e5%bf%ab%e9%80%9f%e4%b9%98","status":"publish","type":"post","link":"https:\/\/blog.kylelv.com\/?p=384","title":{"rendered":"bzoj 4766: \u6587\u827a\u8ba1\u7b97\u59ec  &#8212; \u5feb\u901f\u4e58"},"content":{"rendered":"<p>&nbsp;<\/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-69fdef40edeb8\" 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-69fdef40edeb8\"  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=384\/#4766_%E6%96%87%E8%89%BA%E8%AE%A1%E7%AE%97%E5%A7%AC\" title=\"4766: \u6587\u827a\u8ba1\u7b97\u59ec\">4766: \u6587\u827a\u8ba1\u7b97\u59ec<\/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=384\/#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=384\/#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=384\/#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=384\/#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=384\/#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=384\/#HINT\" title=\"HINT\">HINT<\/a><\/li><\/ul><\/nav><\/div>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"4766_%E6%96%87%E8%89%BA%E8%AE%A1%E7%AE%97%E5%A7%AC\"><\/span>4766: \u6587\u827a\u8ba1\u7b97\u59ec<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: center;\"><span class=\"green\">Time Limit:\u00a01 Sec\u00a0\u00a0Memory Limit:\u00a0128 MB<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Description\"><\/span>Description<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<div>&#8220;\u594b\u6218\u4e09\u661f\u671f\uff0c\u9020\u53f0\u8ba1\u7b97\u673a&#8221;\u3002\u5c0fW\u54cd\u5e94\u53f7\u53ec\uff0c\u82b1\u4e86\u4e09\u661f\u671f\u9020\u4e86\u53f0\u6587\u827a\u8ba1\u7b97\u59ec\u3002\u6587\u827a\u8ba1\u7b97\u59ec\u6bd4\u666e\u901a\u8ba1\u7b97\u673a\u6709\u66f4\u591a\u7684\u827a<\/div>\n<div>\u672f\u7ec6\u80de\u3002\u666e\u901a\u8ba1\u7b97\u673a\u80fd\u8ba1\u7b97\u4e00\u4e2a\u5e26\u6807\u53f7\u5b8c\u5168\u56fe\u7684\u751f\u6210\u6811\u4e2a\u6570\uff0c\u800c\u6587\u827a\u8ba1\u7b97\u59ec\u80fd\u8ba1\u7b97\u4e00\u4e2a\u5e26\u6807\u53f7\u5b8c\u5168\u4e8c\u5206\u56fe\u7684\u751f\u6210\u6811<\/div>\n<div>\u4e2a\u6570\u3002\u66f4\u5177\u4f53\u5730\uff0c\u7ed9\u5b9a\u4e00\u4e2a\u4e00\u8fb9\u70b9\u6570\u4e3an\uff0c\u53e6\u4e00\u8fb9\u70b9\u6570\u4e3am\uff0c\u5171\u6709n*m\u6761\u8fb9\u7684\u5e26\u6807\u53f7\u5b8c\u5168\u4e8c\u5206\u56feK_{n,m}\uff0c\u8ba1\u7b97\u59ec\u80fd\u5feb<\/div>\n<div>\u901f\u7b97\u51fa\u5176\u751f\u6210\u6811\u4e2a\u6570\u3002\u5c0fW\u4e0d\u77e5\u9053\u8ba1\u7b97\u59ec\u7b97\u7684\u5bf9\u4e0d\u5bf9\uff0c\u4f60\u80fd\u5e2e\u52a9\u4ed6\u5417\uff1f<\/div>\n<div><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Input\"><\/span>Input<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<div>\u4ec5\u4e00\u884c\u4e09\u4e2a\u6574\u6570n,m,p\uff0c\u8868\u793a\u7ed9\u51fa\u7684\u5b8c\u5168\u4e8c\u5206\u56feK_{n,m}<\/div>\n<div>1 &lt;= n,m,p &lt;= 10^18<\/div>\n<div><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Output\"><\/span>Output<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<div>\u4ec5\u4e00\u884c\u4e00\u4e2a\u6574\u6570\uff0c\u8868\u793a\u5b8c\u5168\u4e8c\u5206\u56feK_{n,m}\u7684\u751f\u6210\u6811\u4e2a\u6570\uff0c\u7b54\u6848\u9700\u8981\u6a21p\u3002<\/div>\n<div><\/div>\n<p>&nbsp;<\/p>\n<\/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\">2 3 7<\/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\">5<\/span><\/div>\n<h2><span class=\"ez-toc-section\" id=\"HINT\"><\/span>HINT<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u6211\u4eec\u53ef\u4ee5\u7528\u77e9\u9635\u6811\u5b9a\u7406\u6216prufer\u5e8f\u5217\u8bc1\u660e\u5176\u751f\u6210\u6811\u4e2a\u6570\u4e3a<img decoding=\"async\" src=\"http:\/\/images2015.cnblogs.com\/blog\/1014417\/201703\/1014417-20170310154838529-256653664.png\" alt=\"\" \/><\/p>\n<p>\u56e0\u4e3a\u7531\u4e8e\u6a21\u6570\u6bd4\u8f83\u5927\uff0c\u4e58\u6cd5\u4f1a\u7206long long \u6240\u4ee5\u9700\u8981\u7528\u5230\u5feb\u901f\u4e58<\/p>\n<pre class=\"lang:c++ decode:true \">#include&lt;cstdio&gt;\r\ntypedef long long ll;\r\ntypedef long double ld;\r\nll n,m,p;\r\nll mul(ll x,ll y){return (x*y-(ll)(((ld)x*y+0.5)\/(ld)p)*p+p)%p;}\r\nll ksm(ll a,ll b)\r\n{\r\n    ll ret=1;\r\n    for(;b;b&gt;&gt;=1,a=mul(a,a))\r\n        if(b&amp;1) ret=mul(ret,a);\r\n    return ret;\r\n}\r\nint main()\r\n{\r\n    scanf(\"%lld%lld%lld\",&amp;n,&amp;m,&amp;p);\r\n    printf(\"%lld\\n\",mul(ksm(n,m-1),ksm(m,n-1)));\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; 4766: \u6587\u827a\u8ba1\u7b97\u59ec Time Limit:\u00a01 Sec\u00a0\u00a0Memory Limit:\u00a0128 [&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-384","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\/384","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=384"}],"version-history":[{"count":2,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/384\/revisions"}],"predecessor-version":[{"id":386,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/384\/revisions\/386"}],"wp:attachment":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=384"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=384"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}