{"id":563,"date":"2019-01-09T21:32:42","date_gmt":"2019-01-09T13:32:42","guid":{"rendered":"http:\/\/SmokeyDays.top\/wordpress\/?p=563"},"modified":"2019-01-09T21:32:42","modified_gmt":"2019-01-09T13:32:42","slug":"lp2150-noi2015-%e5%af%bf%e5%8f%b8%e6%99%9a%e5%ae%b4","status":"publish","type":"post","link":"http:\/\/SmokeyDays.top\/wordpress\/2019\/01\/09\/lp2150-noi2015-%e5%af%bf%e5%8f%b8%e6%99%9a%e5%ae%b4\/","title":{"rendered":"lp2150 NOI2015 \u5bff\u53f8\u665a\u5bb4"},"content":{"rendered":"\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p> \u5c062~n\u7684\u6574\u6570\u5212\u5206\u5230\u4e24\u4e2a\u96c6\u5408\uff0c\u4f7f\u5f97\u4e24\u4e2a\u96c6\u5408\u4e2d\u4efb\u610f\u4e24\u4e2a\u5143\u7d20\u4e92\u8d28\uff0c\u6c42\u65b9\u6848\u6570\u3002<br> \u5bf9\u4e8en&lt;=30\u7684\u60c5\u51b5\u662f\u5f88\u5bb9\u6613\u60f3\u5230\u7684\uff0c\u5c06\u6bcf\u4e2a\u6570\\(i\\)\u6c42\u51fa\u5b83\u7684\u8d28\u56e0\u5b50\u96c6\u5408\\(K_{i}\\)\u3002<br> \u5f88\u5bb9\u6613\u53ef\u4ee5\u53d1\u73b0\uff0c30\u4ee5\u5185\u7684\u8d28\u6570\u4ec5\u670910\u79cd\u3002\u6545\u800c\u6211\u4eec\u5c31\u6709\u4e86\u4e00\u4e2a\\(O(2^{20<em>2}<\/em>n)\\)\u7684\u505a\u6cd5\u3002<br> \u5bf9\u4e8en&lt;=500\u7684\u60c5\u51b5\uff0c\u4f3c\u4e4e\u7528\u4e0a\u8ff0\u7684\u505a\u6cd5\u5e76\u4e0d\u662f\u5341\u5206\u53ef\u884c\uff0c\u65e0\u8bba\u662f\u65f6\u95f4\u590d\u6742\u5ea6\u8fd8\u662f\u7a7a\u95f4\u590d\u6742\u5ea6\u90fd\u662f\u4e0d\u53ef\u63a5\u53d7\u7684\u3002<br> \u4f46\u662f\u6211\u4eec\u53d1\u73b0\uff0c\u6709\u4e14\u4ec5\u67097\u4e2a\u8d28\u6570\uff0c\u5728500\u4ee5\u5185\u4f1a\u4f5c\u4e3a\u56e0\u6570\u51fa\u73b0\u591a\u6b21\u3002\u6211\u4eec\u662f\u4e0d\u662f\u53ef\u4ee5\u7528\u4e00\u79cd\u5947\u6280\u6deb\u5de7\u628a\u5927\u4e8e19\u7684\u8d28\u6570\u5904\u7406\u6389\u5462\uff1f<br> \u6211\u4eec\u60ca\u8bb6\u5730\u53d1\u73b0\uff0c\u7531\u4e8e\u6240\u6709\u8f83\u5927\u7684\u8d28\u6570\u4f1a\u4e14\u53ea\u4f1a\u51fa\u73b0\u4e00\u6b21\uff0c\u90a3\u4e48\u5f88\u663e\u7136\u6240\u6709\u6700\u5927\u8d28\u56e0\u5b50\u662f\u8f83\u5927\u8d28\u6570\u4e14\u6700\u5927\u8d28\u56e0\u5b50\u76f8\u540c\u7684\u6570\u53ea\u80fd\u653e\u5230\u4e00\u4e2a\u96c6\u5408\u91cc\u3002<br> \u6545\u800c\u6211\u4eec\u628a\u6240\u6709\u6570\u6309\u7167\u6700\u5927\u8d28\u56e0\u5b50\u6392\u5e8f\uff0c\u7136\u540e\u4ece\u5c0f\u5230\u5927\u904d\u5386\u3002\u5f53\u6700\u5927\u8d28\u56e0\u5b50\u6210\u4e3a\u8f83\u5927\u8d28\u6570\u7684\u65f6\u5019\uff0c\u4e0d\u518d\u4f7f\u7528\u539f\u6765\u7684\u6570\u7ec4\uff0c\u800c\u662f\u5c06\u300c\u8fd9\u4e2a\u8d28\u56e0\u5b50\u4e00\u4e2a\u90fd\u6ca1\u9009\u300d\u7684\u60c5\u51b5\u590d\u5236\u5230\u4e24\u4e2a\u65b0\u7684\u6570\u7ec4f2[2][1&lt;&lt;7][1&lt;&lt;7]\u3002<br> \u6bcf\u4e00\u6b21\u66f4\u6362\u6700\u5927\u8d28\u56e0\u5b50\u7684\u65f6\u5019\u90fd\u4ece\u539f\u6570\u7ec4\u7ee7\u627fDP\u503c\uff0c\u7136\u540e\u5728\u8fd9\u91cc\u9762\u5bf9\u6bcf\u4e00\u4e2a\u662f\u653e\u5728A\u8fd8\u662f\u653e\u5728B\u7684\u60c5\u51b5\u6765\u66f4\u65b0\uff1a<\/p>\n\n\n\n<p>$$f_{S_1,S_2} = f2_{0,S_1,S_2} + f2_{1,S_1,S_2} &#8211; f_{S_1,S_2}$$<\/p>\n\n\n\n<p>\u4e4b\u6240\u4ee5\u6700\u540e\u8fd8\u8981\u51cf\u53bb\u539f\u6765\u7684\u503c\u662f\u56e0\u4e3a\uff0c\u4e24\u4e2a\u65b0\u6570\u7ec4\u7684\u6700\u7ec8\u7ed3\u679c\u5404\u81ea\u90fd\u662f\u4ece\u539f\u6765\u7684\u300c\u8fd9\u4e2a\u8d28\u56e0\u5b50\u4e00\u4e2a\u90fd\u6ca1\u9009\u300d\u7684\u60c5\u51b5\u590d\u5236\u8fc7\u6765\u7684\uff0c\u56e0\u6b64\u300c\u8fd9\u4e2a\u8d28\u56e0\u5b50\u4e00\u4e2a\u90fd\u6ca1\u9009\u300d\u7684\u60c5\u51b5\u5c31\u4f1a\u88ab\u7edf\u8ba1\u4e24\u6b21\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream>\n#include&lt;cstdio>\n#include&lt;algorithm>\n\/*\n\n*\/ \nconst int P[8]={2,3,5,7,11,13,17,19};\nconst int MAX=1&lt;&lt;8;\nlong long MOD;\nlong long f[MAX][MAX],f2[2][MAX][MAX];\nstruct data{\n\tint v;\n\tint big;\n\tint K;\n\tinline void init(int X){\n\t\tv=X,big=0;\n\t\tint nw=v;K=0;\n\t\tfor(int i=0;i&lt;8;++i){\n\t\t\tif(!(nw%P[i])){\n\t\t\t\tK|=(1&lt;&lt;i);\n\t\t\t}\n\t\t\twhile(!(nw%P[i])){\n\t\t\t\tnw\/=P[i];\n\t\t\t}\n\t\t}\n\t\tif(nw>1){\n\t\t\tbig=nw;\n\t\t}\n\t}\n\tinline bool operator&lt;(const data &amp;B)const{\n\t\treturn big&lt;B.big;\n\t}\n}a[505];\nint n;\nvoid init(){\n\tscanf(\"%d%lld\",&amp;n,&amp;MOD);\n\t--n;\n\tfor(int i=1;i&lt;=n;++i){\n\t\ta[i].init(i+1);\n\t}\n\tstd::sort(a+1,a+1+n);\n\tint lst=0x3f3f3f3f;\n\tf[0][0]=1;\n\tfor(int i=1;i&lt;=n;++i){\n\t\tif(a[i].big){\n\t\t\tlst=i;\n\t\t\tbreak;\n\t\t}\n\t\tfor(int j=MAX-1;~j;--j){\n\/\/\t\t\t\u6ce8\u610f\u8fd9\u91cc\u8981-1 \n\t\t\tfor(int k=MAX-1;~k;--k){\n\t\t\t\tf[j][k|a[i].K]+=f[j][k];f[j|a[i].K][k]+=f[j][k];\n\t\t\t\tf[j][k|a[i].K]%=MOD;f[j|a[i].K][k]%=MOD;\n\t\t\t}\n\t\t}\n\t}\n\tfor(int i=lst;i&lt;=n;++i){\n\t\tif(a[i].big!=a[i-1].big){\n\t\t\tfor(int j=0;j&lt;MAX;++j){\n\t\t\t\tfor(int k=0;k&lt;MAX;++k){\n\t\t\t\t\tf2[0][j][k]=f2[1][j][k]=f[j][k];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int j=MAX-1;~j;--j){\n\t\t\tfor(int k=MAX-1;~k;--k){\n\t\t\t\tif(j&amp;k){\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif(!(k&amp;a[i].K)){\n\t\t\t\t\tf2[0][j|a[i].K][k]+=f2[0][j][k];\n\t\t\t\t\tf2[0][j|a[i].K][k]%=MOD;\n\t\t\t\t}\n\t\t\t\tif(!(j&amp;a[i].K)){\n\t\t\t\t\tf2[1][j][k|a[i].K]+=f2[1][j][k];\n\t\t\t\t\tf2[1][j][k|a[i].K]%=MOD;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(a[i].big!=a[i+1].big){\n\t\t\tfor(int j=0;j&lt;MAX;++j){\n\t\t\t\tfor(int k=0;k&lt;MAX;++k){\n\t\t\t\t\tf[j][k]=(f2[0][j][k]+f2[1][j][k]+(MOD-f[j][k]))%MOD;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tlong long ans=0;\n\tfor(int i=MAX-1;~i;--i){\n\t\tfor(int j=MAX-1;~j;--j){\n\t\t\tif(i&amp;j){\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tans+=f[i][j];\n\t\t\tans%=MOD;\n\t\t}\n\t}\n\tprintf(\"%lld\\n\",ans);\n}\n\nint main(){\n\tinit();\n\treturn 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5c062~n\u7684\u6574\u6570\u5212\u5206\u5230\u4e24\u4e2a\u96c6\u5408\uff0c\u4f7f\u5f97\u4e24\u4e2a\u96c6\u5408\u4e2d\u4efb\u610f\u4e24\u4e2a\u5143\u7d20\u4e92\u8d28\uff0c\u6c42\u65b9\u6848\u6570\u3002 \u5bf9\u4e8en&lt;=30\u7684\u60c5\u51b5\u662f\u5f88\u5bb9\u6613\u60f3 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/SmokeyDays.top\/wordpress\/2019\/01\/09\/lp2150-noi2015-%e5%af%bf%e5%8f%b8%e6%99%9a%e5%ae%b4\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201clp2150 NOI2015 \u5bff\u53f8\u665a\u5bb4\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[50,34,8,39,6,5],"tags":[],"_links":{"self":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/563"}],"collection":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/comments?post=563"}],"version-history":[{"count":1,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/563\/revisions"}],"predecessor-version":[{"id":564,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/563\/revisions\/564"}],"wp:attachment":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/media?parent=563"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/categories?post=563"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/tags?post=563"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}