{"id":598,"date":"2024-06-21T09:00:00","date_gmt":"2024-06-21T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=598"},"modified":"2024-06-25T16:55:53","modified_gmt":"2024-06-25T08:55:53","slug":"zerojudge-d120","status":"publish","type":"post","link":"https:\/\/seanxd.com\/zh\/zerojudge-d120\/","title":{"rendered":"ZeroJudge D120: Count the factors"},"content":{"rendered":"\n\n\n<h4 class=\"wp-block-heading\">\u540c\u984c\uff1aUVa 10699 &#8211; Count the factors<\/h4>\n\n\n\n<p>\u5beb\u4e00\u500b\u7a0b\u5f0f\u7b97\u51fa\u4e00\u500b\u6b63\u6574\u6578\u6709\u591a\u5c11\u500b\u4e0d\u540c\u7684\u8cea\u56e0\u6578\u3002\u4f8b\u5982\uff1a45 = 3<em>3<\/em>5\uff0c\u6240\u4ee5 45 \u6709 2 \u500b\u8cea\u56e0\u6578 (3 \u548c 5\uff09\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7bc4\u4f8b\u6e2c\u8cc7<\/h2>\n\n\n\n<figure class=\"wp-block-table nfd-wb-animate nfd-wb-fade-in-bottom-short\"><table class=\"has-fixed-layout\"><thead><tr><th>\u7bc4\u4f8b\u8f38\u5165<\/th><th>\u7bc4\u4f8b\u8f38\u51fa<\/th><\/tr><\/thead><tbody><tr><td>\u6bcf\u7d44\u6e2c\u8a66\u8cc7\u6599\u4e00\u5217\u3002\u542b\u6709 1 \u500b\u6b63\u6574\u6578 N (1 &lt; N &lt;= 1000000\uff09\u3002<br>\u82e5 N = 0 \u4ee3\u8868\u8f38\u5165\u7d50\u675f\u3002<\/td><td>\u5c0d\u6bcf\u7d44\u6e2c\u8a66\u8cc7\u6599\u8f38\u51fa\u4e00\u5217\uff0cN \u6709\u591a\u5c11\u500b\u4e0d\u540c\u7684\u8cea\u56e0\u6578\u3002\u8f38\u51fa\u683c\u5f0f\u8acb\u53c3\u8003 Sample Output\u3002<\/td><\/tr><tr><td>7<br>8<br>45<br>289384<br>930887<br>692778<br>636916<br>747794<br>238336<br>885387<br>760493<br>516650<br>641422<br>0<\/td><td>7 : 1<br>8 : 1<br>45 : 2<br>289384 : 3<br>930887 : 2<br>692778 : 5<br>636916 : 4<br>747794 : 3<br>238336 : 3<br>885387 : 2<br>760493 : 2<br>516650 : 3<br>641422 : 3<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p>\u53ef\u4ee5\u5275\u5efa\u4e00\u500b\u51fd\u5f0f\u53bb\u5224\u65b7\u4e00\u500b\u6578\u5b57\u662f\u5426\u70ba\u8cea\u6578\u3002\u4f7f\u7528 For\u8ff4\u5708 \u5f9e 2 \u5230 N\uff0c\u5982\u679c\u627e\u5230 N \u7684\u56e0\u6578\u5c31\u5224\u65b7\u5176\u662f\u5426\u70ba\u8cea\u6578\uff0c\u5982\u679c\u662f\u8cea\u6578\u5c31\u5c07\u7b54\u6848 +1\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=d120\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge D120: Count the factors<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap nfd-wb-animate nfd-wb-reveal-right nfd-delay-50\"><pre class=\"prism line-numbers lang-cpp\" data-lang=\"C++\"><code>#include &lt;iostream&gt;\n#include &lt;math.h&gt;\nusing namespace std;\n\nbool isPrime(int N) {\n    for (int i = 2; i&lt;int(sqrt(N)+1); i++) {\n        if (N % i == 0) return false;\n    }\n    return true;\n}\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    int N;\n    while (cin &gt;&gt; N && N != 0) {\n        int ans = 0;\n        for (int i = 2; i&lt;=N; i++) {\n            if (N % i == 0 && isPrime(i)) {\n                ans++;\n            }\n        }\n        cout &lt;&lt; N &lt;&lt; &quot; : &quot; &lt;&lt; ans &lt;&lt; &quot;\\n&quot;;\n    }\n}\n\n\/\/ZeroJudge D120\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u540c\u984c\uff1aUVa 10699 &#8211; Count the factors \u5beb\u4e00\u500b\u7a0b\u5f0f\u7b97\u51fa\u4e00\u500b\u6b63\u6574\u6578\u6709\u591a\u5c11\u500b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","footnotes":""},"categories":[18],"tags":[8,34,13,9],"class_list":["post-598","post","type-post","status-publish","format-standard","hentry","category-uva","tag-8","tag-34","tag-13","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/598","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/comments?post=598"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/598\/revisions"}],"predecessor-version":[{"id":991,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/598\/revisions\/991"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/media?parent=598"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/categories?post=598"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/tags?post=598"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}