{"id":260,"date":"2016-11-23T14:22:03","date_gmt":"2016-11-23T06:22:03","guid":{"rendered":"http:\/\/kylelv.com\/?p=260"},"modified":"2017-12-13T13:16:55","modified_gmt":"2017-12-13T05:16:55","slug":"bzoj-1666-usaco2006-octanother-cow-number-game-%e5%a5%b6%e7%89%9b%e7%9a%84%e6%95%b0%e5%ad%97%e6%b8%b8%e6%88%8f","status":"publish","type":"post","link":"https:\/\/blog.kylelv.com\/?p=260","title":{"rendered":"bzoj 1666: [Usaco2006 Oct]Another Cow Number Game \u5976\u725b\u7684\u6570\u5b57\u6e38\u620f"},"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-69fdef601adc9\" 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-69fdef601adc9\"  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=260\/#1666_Usaco2006_OctAnother_Cow_Number_Game_%E5%A5%B6%E7%89%9B%E7%9A%84%E6%95%B0%E5%AD%97%E6%B8%B8%E6%88%8F\" title=\"1666: [Usaco2006 Oct]Another Cow Number Game \u5976\u725b\u7684\u6570\u5b57\u6e38\u620f\">1666: [Usaco2006 Oct]Another Cow Number Game \u5976\u725b\u7684\u6570\u5b57\u6e38\u620f<\/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=260\/#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=260\/#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=260\/#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=260\/#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=260\/#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=260\/#HINT\" title=\"HINT\">HINT<\/a><\/li><\/ul><\/nav><\/div>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"1666_Usaco2006_OctAnother_Cow_Number_Game_%E5%A5%B6%E7%89%9B%E7%9A%84%E6%95%B0%E5%AD%97%E6%B8%B8%E6%88%8F\"><\/span>1666: [Usaco2006 Oct]Another Cow Number Game \u5976\u725b\u7684\u6570\u5b57\u6e38\u620f<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span class=\"green\">Time Limit:\u00a05 Sec\u00a0\u00a0Memory Limit:\u00a064 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<p>\u5976\u725b\u4eec\u53c8\u5728\u73a9\u4e00\u79cd\u65e0\u804a\u7684\u6570\u5b57\u6e38\u620f\u3002\u8f93\u5f97\u5f88\u90c1\u95f7\u7684\u8d1d\u831c\u60f3\u8bf7\u4f60\u5199\u4e2a\u7a0b\u5e8f\u6765\u5e2e\u5979\u5728\u5f00\u5c40\u65f6\u9884\u6d4b\u7ed3\u679c\u3002\u5728\u6e38\u620f\u7684\u5f00\u59cb\uff0c\u6bcf\u5934\u725b\u90fd\u4f1a\u5f97\u5230\u4e00\u4e2a\u6570N(1&lt;=N&lt;=1,000,000)\u3002\u6b64\u65f6\u5976\u725b\u4eec\u7684\u5206\u6570\u5747\u4e3a0\u3002\u5982\u679cN\u662f\u5947\u6570\uff0c\u90a3\u4e48\u5976\u725b\u5c31\u4f1a\u628a\u5b83\u4e58\u4ee53\u540e\u518d\u52a01\u3002\u5982\u679cN\u662f\u5076\u6570\uff0c\u90a3\u4e48\u8fd9\u4e2a\u6570\u5c31\u4f1a\u88ab\u9664\u4ee52\u3002\u6570\u5b57\u6bcf\u53d8\u52a8\u4e00\u6b21\uff0c\u8fd9\u5934\u5976\u725b\u5c31\u5f97\u52301\u5206\u3002\u5f53N\u7684\u503c\u7b49\u4e8e1\u65f6\uff0c\u6e38\u620f\u7ed3\u675f\uff0c\u6b64\u65f6\u7684\u5206\u6570\u5c31\u662f\u8fd9\u5934\u5976\u725b\u5728\u8fd9\u5c40\u6e38\u620f\u4e2d\u7684\u6700\u7ec8\u5f97\u5206\u3002 \u4ee5\u4e0b\u662fN\u7684\u521d\u59cb\u503c\u4e3a5\u65f6\uff0c\u4e00\u5c40\u6e38\u620f\u7684\u5b8c\u6574\u8fc7\u7a0b\uff1a N \u64cd\u4f5c\u540e\u6240\u5f97\u6570 \u6ce8\u91ca \u603b\u5206 5 16 3*5+1 1 16 8 16\/2 2 8 4 8\/2 3 4 2 4\/2 4 2 1 2\/2 5 \u8fd9\u5934\u5976\u725b\u7684\u6700\u7ec8\u5f97\u5206\u662f5\u3002<\/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<p>* \u7b2c1\u884c: \u4e00\u4e2a\u6b63\u6574\u6570\uff0cN<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Output\"><\/span>Output<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>&nbsp;<\/p>\n<div class=\"content\">\n<p>* \u7b2c1\u884c: \u8f93\u51fa\u4e00\u4e2a\u6b63\u6574\u6570N\uff0c\u5373\u5976\u725b\u5728\u8fd9\u5c40\u6e38\u620f\u4e2d\u7684\u6700\u7ec8\u5f97\u5206<\/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\">112<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\">20<\/span><\/div>\n<h2><span class=\"ez-toc-section\" id=\"HINT\"><\/span>HINT<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><\/h2>\n<pre class=\"lang:c++ decode:true\">#include&lt;cstdio&gt;\r\nint n,ans;\r\nint main()\r\n{\r\n    scanf(\"%d\",&amp;n);\r\n    while(n!=1)\r\n    {\r\n        n&amp;1?n=n*3+1:n&gt;&gt;=1;\r\n        ans++;\r\n    }\r\n    printf(\"%d\",ans);\r\n}<\/pre>\n<div class=\"content\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; 1666: [Usaco2006 Oct]Another Cow Number Game \u5976\u725b\u7684 [&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":[8],"class_list":["post-260","post","type-post","status-publish","format-standard","hentry","category-bzoj","tag-8"],"_links":{"self":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/260","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=260"}],"version-history":[{"count":2,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/260\/revisions"}],"predecessor-version":[{"id":266,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/260\/revisions\/266"}],"wp:attachment":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=260"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}