{"id":49,"date":"2022-06-04T10:52:00","date_gmt":"2022-06-04T02:52:00","guid":{"rendered":"http:\/\/ubuntu.tim-wcx.ltd\/wordpress\/index.php\/2022\/06\/04\/%e5%bc%82%e6%88%96%e6%b1%82%e5%92%8c%e5%bc%8f\/"},"modified":"2022-06-04T10:52:00","modified_gmt":"2022-06-04T02:52:00","slug":"%e5%bc%82%e6%88%96%e6%b1%82%e5%92%8c%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/wordpress.tim-wcx.ltd\/index.php\/2022\/06\/04\/%e5%bc%82%e6%88%96%e6%b1%82%e5%92%8c%e5%bc%8f\/","title":{"rendered":"\u5f02\u6216\u6c42\u548c\u5f0f"},"content":{"rendered":"<p><svg  style=\"display: none;\">\n                        <path stroke-linecap=\"round\" d=\"M5,0 0,2.5 5,5z\" id=\"raphael-marker-block\" style=\"-webkit-tap-highlight-color: rgba(0, 0, 0, 0);\"><\/path>\n                    <\/svg><\/p>\n<h1><a id=\"_0\"><\/a>\u5f02\u6216\u6c42\u548c\u5f0f<\/h1>\n<p>\u53c2\u8003\u4e8e\uff1a<a href=\"https:\/\/blog.csdn.net\/ECNU_LZJ\/article\/details\/72853774?utm_medium=distribute.pc_relevant.none-task-blog-OPENSEARCH-1.nonecase&#038;depth_1-utm_source=distribute.pc_relevant.none-task-blog-OPENSEARCH-1.nonecase\">https:\/\/blog.csdn.net\/ECNU_LZJ\/article\/details\/72853774?utm_medium=distribute.pc_relevant.none-task-blog-OPENSEARCH-1.nonecase&#038;depth_1-utm_source=distribute.pc_relevant.none-task-blog-OPENSEARCH-1.nonecase<\/a><\/p>\n<h3><a id=\"_2\"><\/a>\u9898\u76ee<\/h3>\n<p>\u7ed9\u5b9a\u957f\u5ea6\u4e3an\u7684\u5e8f\u5217A[i]\uff0c\u6c42\u6240\u6709A[i] xor A[j] (i<j)\u7684\u503c\u4e4b\u548c<\/p>\n<h3><a id=\"_4\"><\/a>\u8f93\u5165<\/h3>\n<p>\u7b2c\u4e00\u884c\u4e00\u4e2a\u6574\u6570N<br \/> \u63a5\u4e0b\u6765N\u884c\uff0c\u7b2ci\u884c\u4e3aA[i]<\/p>\n<h3><a id=\"_7\"><\/a>\u8f93\u51fa<\/h3>\n<p>\u6240\u9700\u7684\u503c<\/p>\n<h3><a id=\"_9\"><\/a>\u6837\u4f8b\u8f93\u5165<\/h3>\n<p>3<br \/> 7 3 5<\/p>\n<h3><a id=\"_12\"><\/a>\u6837\u4f8b\u8f93\u51fa<\/h3>\n<p>12<\/p>\n<h3><a id=\"_14\"><\/a>\u6837\u4f8b\u89e3\u91ca<\/h3>\n<p>7 xor 3+3 xor 5+7 xor 5 = 4+6+2 = 12<\/p>\n<h3><a id=\"_17\"><\/a>\u9898\u89e3<\/h3>\n<p>\u5f02\u6216\uff1aC++\u4e2d\u5373\u4e3a ^ \u8fd0\u7b97\u7b26<br \/> 0^0=0 , 0^1=1 ,1^0=1, 1^1=0<\/p>\n<p>\u6570\u5b57\u90fd\u5316\u6210\u4e8c\u8fdb\u5236\uff1a7:111, 3:011, 5:101<br \/> \u5f02\u6216\u5177\u6709\u4ea4\u6362\u5f8b\uff0c\u4e5f\u5c31\u662f\u8bf4\u53ea\u8981\u80fd\u591f\u4f7f\u5f97\u4efb\u610f\u4e24\u4e2a\u6570\u5b57\u90fd\u5f02\u6216\u4e00\u6b21\uff0c\u5c31\u6ca1\u6709\u5fc5\u8981\u6bcf\u6b21\u7528\u524d\u9762\u7684\u6570\u5b57\u5f02\u6216\u540e\u9762\u7684\u6570\u5b57\u3002\u8fd9\u542f\u53d1\u6211\u4eec\u4e0d\u5173\u6ce8\u5f02\u6216\u7684\u987a\u5e8f\uff0c\u800c\u662f\u5173\u6ce8\u7ed3\u679c\u3002<br \/> \u6613\u77e5\uff1aa\u4e2a1\uff0cb\u4e2a0\u4e24\u4e24\u5f02\u6216\u7684\u7ed3\u679c\u80af\u5b9a\u662fa*b\u4e2a1\uff0c\u5176\u4f59\u90fd\u662f0\u3002<br \/> \u4e09\u4e2a\u6570\u5b57\u7684\u6700\u4f4e\u4f4d\u5206\u522b\u662f1,1,1\uff0c\u4e5f\u5c31\u662f\u4e09\u4e2a1\u3002\u90a3\u4e48\u6700\u4f4e\u4f4d\u5f02\u6216\u7684\u7ed3\u679c\u4e00\u5b9a\u662f\u96f6\u4e2a1\uff0c\u4e09\u4e2a0\uff0c\u76f8\u52a0\u4e3a0\u3002<br \/> \u6b21\u4f4e\u4f4d\u5206\u522b\u662f1,1,0\uff0c\u4e5f\u5c31\u662f\u4e24\u4e2a1\u4e00\u4e2a0\u3002\u90a3\u4e48\u6b21\u4f4e\u4f4d\u5f02\u6216\u7684\u7ed3\u679c\u4e00\u5b9a\u662f\u4e24\u4e2a1\uff0c\u4e00\u4e2a0\uff0c\u76f8\u52a0\u4e3a2\u3002<br \/> \u6700\u9ad8\u4f4d\u5206\u522b\u662f1,0,1\uff0c\u4e5f\u5c31\u662f\u4e24\u4e2a1\u4e00\u4e2a0\u3002\u90a3\u4e48\u6700\u9ad8\u4f4d\u5f02\u6216\u7684\u7ed3\u679c\u4e00\u5b9a\u662f\u4e24\u4e2a1\uff0c\u4e00\u4e2a0\uff0c\u76f8\u52a0\u4e3a2\u3002<br \/> \u6240\u4ee5\u6700\u540e\u7684\u7b54\u6848\u5e94\u8be5\u662f<br \/> <img decoding=\"async\" src=\"https:\/\/img-blog.csdnimg.cn\/20200530211612801.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\"><br \/> \u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre><code>#include <iostream>\n#include <bits\/stdc++.h>\nusing namespace std;\nlong long b[50]={0};\nint main()\n{\n    int n;\n    scanf(\"%d\",&n);\n    long long a;\n    for(int i=1;i<=n;i++)\n    {\n        scanf(\"%lld\",&#038;a);\n        int cnt=0;\n        while(a)\n        {\n            cnt++;\n            if(a%2==1)\n            {\n                b[cnt]++;\n            }\n            a=a\/2;\n        }\n    }\n    long long sum=0;\n    for(int i=0;i<=31;i++)\n    {\n        sum=sum+(1<<i)*(b[i+1])*(n-b[i+1]);  \/\/b[i+1]\u4e3a1\u7684\u4e2a\u6570\uff0cn-b[i+1]\u4e3a0\u7684\u4e2a\u6570,1<<i\u4e3a2\u7684i\u6b21\u5e42\n    }\n    cout<<sum<<endl;\n    return 0;\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5f02\u6216\u6c42\u548c\u5f0f \u53c2\u8003\u4e8e\uff1ahttps:\/\/blog.cs&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-49","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/wordpress.tim-wcx.ltd\/index.php\/wp-json\/wp\/v2\/posts\/49","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.tim-wcx.ltd\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.tim-wcx.ltd\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.tim-wcx.ltd\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.tim-wcx.ltd\/index.php\/wp-json\/wp\/v2\/comments?post=49"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.tim-wcx.ltd\/index.php\/wp-json\/wp\/v2\/posts\/49\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.tim-wcx.ltd\/index.php\/wp-json\/wp\/v2\/media?parent=49"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.tim-wcx.ltd\/index.php\/wp-json\/wp\/v2\/categories?post=49"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.tim-wcx.ltd\/index.php\/wp-json\/wp\/v2\/tags?post=49"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}