{"id":105,"date":"2026-04-04T17:43:36","date_gmt":"2026-04-04T09:43:36","guid":{"rendered":"https:\/\/blog.kiloming.top\/?p=105"},"modified":"2026-04-04T17:43:37","modified_gmt":"2026-04-04T09:43:37","slug":"%e7%ae%97%e6%b3%95%e4%b9%a0%e9%a2%98day2","status":"publish","type":"post","link":"https:\/\/blog.kiloming.top\/?p=105","title":{"rendered":"\u7b97\u6cd5\u4e60\u9898Day2"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u524d\u8a00<\/h2>\n\n\n\n<p>    \u4eca\u5929\u4e3b\u8981\u7ec3\u4e60\u524d\u7f00\u548c\uff0c\u6709\u7684\u662f\u4e4b\u524d\u5199\u7684\uff0c\u6e90\u4ee3\u7801\u89c1 <a href=\"https:\/\/github.com\/KiloMing\/MyCode\">https:\/\/github.com\/KiloMing\/MyCode<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">P8649 k\u500d\u533a\u95f4<\/h2>\n\n\n\n<p>\u539f\u9898\u94fe\u63a5\uff1a<a href=\"https:\/\/www.luogu.com.cn\/problem\/P8649\">https:\/\/www.luogu.com.cn\/problem\/P8649<\/a>   \u591a\u6ce8\u610f\u8f6c\u6362\u601d\u60f3\uff0c\u4e0d\u8981\u4e00\u4e0a\u6765\u5c31\u66b4\u529b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\u524d\u7f00\u548c->\u533a\u95f4\u548c\uff0c \u8f6c\u6362\u4e3a\u662f\u5426\u4e3aK\u7684\u500d\u6570\n#include &lt;iostream>\n#include &lt;vector>\n#include &lt;unordered_map>\nusing namespace std;\nint main(){\n    int N, k;\n    cin >> N >> k;\n    vector&lt;int> a(N);\n    vector&lt;long long> s(N+1);\n    unordered_map&lt;int, int> mp1;\n    s&#91;0] = 0;                       \/\/\u521d\u59cb\u5316\n    \/\/cout &lt;&lt; endl;\n    for(int i = 0; i &lt; N; i++){\n        cin >> a&#91;i];\n        \/\/cout &lt;&lt; a&#91;i] &lt;&lt; endl;\n    }\n    for(int i = 1; i &lt;= N; i++){\n        s&#91;i] = s&#91;i-1] + a&#91;i-1];\n        \/\/cout &lt;&lt; s&#91;i] &lt;&lt; endl;\n    }\n    \/\/cout &lt;&lt; endl;\n\n    \/*\u4f7f\u7528\u66b4\u529b\u5199\u51fa\u6240\u6709\u7ed3\u679c\uff0c\u6709\u6ca1\u6709\u66f4\u597d\u7684\u65b9\u6cd5\uff1f\n    \u610f\u6599\u4e4b\u5185\uff0c\u7ed9\u6211\u8e39\u56de\u6765\u4e86\uff1b\n    int sum = 0;\n    for(int i = 1; i &lt;= N; i++){\n        for(int j = i; j &lt;= N; j++){\n            if((s&#91;j]-s&#91;i-1]) % k == 0) sum++;  \/\/\u8fd8\u662f\u8981\u6ce8\u610f\u8fb9\u754c\u95ee\u9898\n        }\n    }\n    *\/\n\n    \/*\n    \u4f7f\u7528\u54c8\u5e0c&lt;unordered_map>,\u8fdb\u884c\u8ba1\u6570\uff0c\u53d1\u73b0\u5982\u679c\u5728\u524d\u7f00\u548c\u6570\u7ec4\u4e2d\uff0c\u5982\u679cs&#91;i] % k = s&#91;j] % k,\u90a3\u4e48\u4ed6\u4eec\u7684\u533a\u95f4\u548c\u5c31\u662fk\u500d\n    \u5728\u5e73\u5e38\u7684\u7b97\u6cd5\u9898\u4e2d\uff0c\u8981\u591a\u6ce8\u610f\u4f7f\u7528\u8f6c\u6362\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5927\u5927\u7b80\u5316\u590d\u6742\u5ea6\n    \/\/\u6253\u597d\u6478\u677f\n    *\/\n    long long ans = 0;   \/\/\u533a\u95f4\u53ef\u80fd\u4f1a\u5f88\u591a\n    for(int i = 0; i &lt;= N; i++){\n        int temp = s&#91;i] % k;\n        ans += mp1&#91;temp];\n        mp1&#91;temp]++;\n    }\n\n    cout &lt;&lt; ans &lt;&lt; endl;\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">P9533 \u533a\u95f4\u7ffb\u8f6c\u533a\u95f4\u5f02\u6216\u548c<\/h2>\n\n\n\n<p>\u539f\u9898\u94fe\u63a5 <a href=\"https:\/\/www.luogu.com.cn\/problem\/P9533\">https:\/\/www.luogu.com.cn\/problem\/P9533<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\n\/\/\u5f02\u6216\uff1a 0^1 = 1; 1^0 = 1, 1^1 = 0, 0^0=0,\u8bf4\u767d\u4e86\u5c31\u662f\u4e00\u6837\u7684\u5c31\u662f0\uff0c\u4e0d\u4e00\u6837\u5c31\u662f1\uff1b\n\/\/\u5728C++\u4e2d\uff0c\u5176\u5e95\u5c42\u8fd0\u7b97\u5c31\u662f\u4e8c\u8fdb\u5236\uff0c\u4e0d\u9700\u8981\u518d\u8fdb\u884c\u4e8c\u8fdb\u5236\u8f6c\u6362\uff0c\u76f4\u63a5\u53ef\u4ee5\u6c42\u51fa\u5f02\u6216\u548c\n\/\/\u9898\u76ee\u4e2d\u8bf4\u53ef\u4ee5\u7ffb\u8f6c\u5f02\u6216\u548c0\u533a\u95f4\uff0c\u4f46\u662f\u65e0\u8bba\u53cd\u8f6c\u8fd8\u662f\u4e0d\u53cd\u8f6c\uff0c\u7ed9\u51fa\u6570\u7ec4\u7684\u6700\u5927\u5f02\u6216\u548c\u90fd\u662f\u4e00\u6837\u7684\uff0c\u6240\u4ee5\u8fd9\u9053\u9898\u5c31\u662f\u6c42\u5f02\u6216\u548c\u4e3a0\u7684\u533a\u95f4\u6709\u591a\u5c11\n\/\/\u5176\u672c\u8d28\u4e0e\u6c42\u533a\u95f4\u548c\u4e3a0\u662f\u4e00\u4e2a\u9053\u7406\n\n#include &lt;iostream>\n#include &lt;vector>\n#include &lt;unordered_map>\nusing namespace std;\nlong long ans = 0;\nlong long sum = 0;\nunordered_map&lt;long long, int> mp1;\n\nint main(){\n    int N;\n    cin >> N;\n    vector&lt;long long> a1(N);\n    for(int i = 0; i &lt; N; i++){\n        cin >> a1&#91;i];\n    }\n    mp1&#91;0] = 1;\n    for(int i = 0; i &lt; N; i++){\n        sum ^= a1&#91;i];\n        ans += mp1&#91;sum];\n        mp1&#91;sum]++;\n    }\n    cout &lt;&lt; ans &lt;&lt; endl;\n\n}\n\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u603b\u7ed3<\/h2>\n\n\n\n<p>\u4ee5\u540e\u518d\u505a\u7b97\u6cd5\u9898\uff0c\u8981\u8003\u8651\u6e05\u695a\uff0c\u8bb2\u6c42\u7ec6\u8282\uff0c\u4eca\u5929\u5c31\u5199\u4e86\u4e24\u9053\uff0c\u6548\u7387\u8fd8\u662f\u6709\u70b9\u4f4e\uff0c\u4e3b\u8981\u662f\u4e0a\u5348\u6478\u7d22\uff0c\u4e0d\u77e5\u9053\u5b66\u5565\uff0c\u4ee5\u540e\u5c31\u8ddf\u7740\u9898\u5355\u505a\u5427<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u4eca\u5929\u4e3b\u8981\u7ec3\u4e60\u524d\u7f00\u548c\uff0c\u6709\u7684\u662f\u4e4b\u524d\u5199\u7684\uff0c\u6e90\u4ee3\u7801\u89c1 https:\/\/github.com\/KiloMing\/M [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":106,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,20,19],"tags":[],"class_list":["post-105","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-text","category-20","category-shuibi"],"_links":{"self":[{"href":"https:\/\/blog.kiloming.top\/index.php?rest_route=\/wp\/v2\/posts\/105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.kiloming.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kiloming.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kiloming.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kiloming.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=105"}],"version-history":[{"count":1,"href":"https:\/\/blog.kiloming.top\/index.php?rest_route=\/wp\/v2\/posts\/105\/revisions"}],"predecessor-version":[{"id":107,"href":"https:\/\/blog.kiloming.top\/index.php?rest_route=\/wp\/v2\/posts\/105\/revisions\/107"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.kiloming.top\/index.php?rest_route=\/wp\/v2\/media\/106"}],"wp:attachment":[{"href":"https:\/\/blog.kiloming.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kiloming.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kiloming.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}