{"id":5556,"date":"2024-09-10T12:01:01","date_gmt":"2024-09-10T04:01:01","guid":{"rendered":""},"modified":"2024-09-10T12:01:01","modified_gmt":"2024-09-10T04:01:01","slug":"\u6269\u5927\u7f16\u7a0b_\u7f16\u7a0b\u5728\u751f\u6d3b\u4e2d\u7684\u5e94\u7528\u7684\u4f8b\u5b50","status":"publish","type":"post","link":"https:\/\/mushiming.com\/5556.html","title":{"rendered":"\u6269\u5927\u7f16\u7a0b_\u7f16\u7a0b\u5728\u751f\u6d3b\u4e2d\u7684\u5e94\u7528\u7684\u4f8b\u5b50"},"content":{"rendered":"

\u7f16\u7a0b\u4e4b\u7f8e\u4e4b\u6269\u5c55\u95ee\u9898
<\/strong><\/p>\n

\u539f\u5e16\u5730\u5740\uff1a\u7f16\u7a0b\u4e4b\u7f8e----\u6269\u5c55\u95ee\u9898<\/strong> <\/p>\n<\/p>\n

\u53c2\u8003\u94fe\u63a5:<\/p>\n

\u7f16\u7a0b\u4e4b\u7f8e----\u6269\u5c55\u95ee\u9898 <\/p>\n

http:\/\/www.cnblogs.com\/wuyuegb2312\/p\/3185083.html <\/p>\n

http:\/\/www.cppblog.com\/flyinghearts\/archive\/2010\/09\/01\/125550.html <\/p>\n

1.1 \u8ba9CPU\u5360\u7528\u7387\u66f2\u7ebf\u542c\u4f60\u6307\u6325<\/p>\n

\u53c2\u8003:<\/p>\n

http:\/\/blog.csdn.net\/wesweeky\/article\/details\/ <\/p>\n

http:\/\/www.cnblogs.com\/chenyuming507950417\/archive\/2012\/09\/14\/2685097.html <\/p>\n

<\/p>\n

1.2 \u4e2d\u56fd\u8c61\u68cb\u5c06\u5e05\u95ee\u9898<\/p>\n

\u89e3\u6cd5\u4e8c\u7528\u8fdb\u5236\u7684\u65b9\u6cd5\u597d\u7406\u89e3\u4e00\u4e9b,\u4f46\u4ee5\u4e0b\u53c2\u8003\u4e2d\u6709\u4eba\u7528\u591a\u91cd\u5faa\u73af\u8f6c\u6362\u7684\u65b9\u5f0f\u89e3\u91ca\u4e5f\u53ef\u4ee5\u7406\u89e3<\/p>\n

\u53c2\u8003:<\/p>\n

http:\/\/book.douban.com\/annotation\/\/ <\/p>\n

http:\/\/blog.csdn.net\/kabini\/article\/details\/ <\/p>\n

http:\/\/blog.csdn.net\/silenceburn\/article\/details\/ <\/p>\n

<\/p>\n

1.3 \u4e00\u645e\u70d9\u997c\u7684\u6392\u5e8f<\/p>\n

\u9012\u5f52\u904d\u5386+\u4e0a\u754c\u4e0b\u754c\u526a\u679d+\u72b6\u6001\u8bb0\u5f55<\/p>\n

\u7f16\u7a0b\u4e4b\u7f8e----\u6269\u5c55\u95ee\u9898 <\/p>\n

\u6269\u5c55\u95ee\u9898:<\/p>\n

1\u591a\u4e86\u4e00\u4e2a\u8111\u888b\u53ef\u4ee5\u653e\u997c,\u901f\u5ea6\u80af\u5b9a\u4f1a\u52a0\u5feb,\u57fa\u672c\u601d\u8def\u662f\u5c06\u997c\u5806\u5206\u4e3a\u4e24\u90e8\u5206,\u7b2c\u4e00\u90e8\u5206\u4e2d\u6700\u5927\u503c\u5c0f\u4e8e\u7b2c\u4e8c\u90e8\u5206(\u6216\u7b2c\u4e00\u90e8\u5206\u6700\u5c0f\u503c\u5927\u4e8e\u7b2c\u4e8c\u90e8\u5206,\u6216\u8005\u8fd9\u6837\u8bf4,\u7b2c\u4e00\u90e8\u5206\u662f\u5927\u5c0f\u662f123,\u7b2c\u4e8c\u90e8\u5206\u662f456,\u53ea\u662f\u90fd\u4e71\u5e8f),\u7136\u540e\u4e24\u90e8\u5206\u5206\u522b\u6392\u5e8f,\u6700\u540e\u518d\u5408\u5e76<\/p>\n

\u53c2\u8003:http:\/\/www.cnblogs.com\/avenxia\/archive\/2012\/09\/13\/2683094.html<\/p>\n

2<\/p>\n

A  \u5148\u6309\u7167\u201c\u70d9\u997c\u6392\u5e8f\u5b9e\u73b0\u201d\u5bf9\u70d9\u997c\u8fdb\u884c\u5927\u5c0f\u6392\u5e8f <\/span>
B  \u7136\u540e\u5bf9\u6709\u91d1\u9ec4\u8272\u4e0d\u671d\u4e0a\u7684\u70d9\u997c\u505a\u5982\u4e0b\u64cd\u4f5c\uff0c\u4ee5cakeArray[k]\u4e3a\u4f8b <\/span>
\u7ffb\u8f6ccakeArray[0:k],\u5c06cakeArray[k]\u7ffb\u5230\u9876\u5c42\uff0c\u7ffb\u8f6ccakeArray[k],\u7136\u540e\u5c06cakeArray[0:k]\u7ffb\u8f6c\uff0c\u5c06cake[k]\u7ffb\u56de\u539f\u6765\u4f4d\u7f6e <\/span><\/p>\n

3\u6982\u7387\u662f2\/3<\/span><\/p>\n

4\u53ef\u4ee5\u731c\u6d4b\u51fa\u5c06\u4f1a\u4f18\u5148\u628a\u6700\u4e0a\u9762\u7684\u90e8\u5206\u6709\u5e8f,\u9010\u6e10\u5230\u4e0b\u9762\u5f62\u6210\u6709\u5e8f,\u5177\u4f53\u7684\u89c4\u5219\u6ca1\u6709\u60f3\u5230,\u4ee3\u7801\u4ecd\u7136\u662f\u904d\u5386,\u53ea\u662f\u5c06\u6b21\u6570\u4f5c\u754c\u9650\u6539\u4e3a\u7ffb\u8f6c\u997c\u4e2a\u6570<\/span><\/p>\n

\u4ecd\u7136\u53c2\u8003:http:\/\/www.cnblogs.com\/avenxia\/archive\/2012\/09\/13\/2683094.html<\/span><\/p>\n

5\u6700\u5927\u4e0b\u529e15N\/14,\u6700\u5c0f\u4e0a\u754c(5N+5)\/3<\/p>\n

\u7b2c14\u4e2a\u70d9\u997c\u6570P14=?<\/p>\n

<\/p>\n

1.4 \u4e70\u4e66\u95ee\u9898<\/p>\n

\u53c2\u8003:<\/p>\n

http:\/\/blog.csdn.net\/kabini\/article\/details\/ \/\/ \u6ce8\u610f\u8bc4\u8bba \u7b2c6\u697c\u4e3e\u7684\u4f8b\u5b50 <\/p>\n

\u8d2a\u5fc3\u7b97\u6cd5\u4e0e\u52a8\u6001\u89c4\u5212\u7684\u7406\u89e3<\/p>\n

\u6b64\u95ee\u9898\u8d2a\u5fc3\u7b97\u6cd5\u4e0d\u9002\u7528(\u6216\u8005\u6682\u65f6\u672a\u627e\u5230\u5408\u9002\u7684\u8d2a\u5fc3\u7b97\u6cd5)<\/p>\n

\u52a8\u6001\u89c4\u5212\u65f6\u95f4\u590d\u6742\u5ea6\u4e3aO(Y1*Y2*Y3*Y4*Y5)\/\/ by zjerry \u5982\u4f55\u7406\u89e3\u8fd9\u4e2a?<\/p>\n

<\/p>\n

1.5 \u5feb\u901f\u627e\u51fa\u6545\u969c\u673a\u5668<\/p>\n

\u5229\u7528O(1)\u7a7a\u95f4\u89e3\u51b3\u552f\u4e00ID\u503c\u4e0d\u540c\u7684\u95ee\u9898,\u9700\u8981\u7528\u5230\u5f02\u6216\u7684\u7279\u6027,\u8fde\u7eed\u5f02\u6216\u53ef\u4ee5\u7406\u89e3\u4e3a\u4f4d\u7684\u8fde\u7eed\u6c42\u5f02\u5b58\u540c(\u5176\u5b9e\u662f\u6c42\u5947\u5f03\u5076),\u6700\u7ec8\u5f97\u5230\u7684\u503c\u5c31\u662f\u552f\u4e00ID\u503c(\u6ca1\u6709\u76f8\u540c\u7684ID\u4e0e\u4ed6\u76f8\u540c\u5f97\u52300)<\/p>\n

\u4e24\u4e2a\u4e0d\u540c\u503c\u6839\u636e\u5f02\u6216\u7ed3\u679c\u67d0\u4e00\u4f4d\u4e0a\u76841,\u5c06\u539fID\u96c6\u5408\u5206\u4e3a\u4e24\u7c7b,\u8be5\u4f4d\u4e0a\u67091\u548c\u65e01,\u518d\u5206\u522b\u8fde\u7eed\u5f02\u6216<\/p>\n

\u53e6\u89e3\u6cd5:\u6784\u9020\u65b9\u7a0b,\u6c42\u4e00\u4e2a\u503c,\u5229\u7528\u539f\u6b63\u5e38ID\u6784\u9020\u548c,\u7136\u540e\u51cf\u53bb\u73b0\u6709,\u5269\u4e0b\u503c\u5373\u4e3a\u6240\u6c42;\u6c42\u4e24\u4e2a\u503c,\u53ef\u4ee5\u6784\u9020x+y,x^2+y^2<\/p>\n

\u6269\u5c55\u95ee\u9898:<\/p>\n

3\u4e2a\u503c\u62163\u4e2a\u4ee5\u4e0a\u7684\u60c5\u51b5\u4e0b\u53ef\u4ee5\u8003\u8651\u6784\u9020\u65b9\u7a0b,<\/p>\n

\u4e5f\u53ef\u4ee5\u8003\u8651\u7528hashMap\u4fdd\u5b58ID,\u7136\u540e\u8fc7\u6ee4\u6b63\u5e38ID<\/p>\n

\u6251\u514b\u95ee\u9898:\u7528\u539f\u548c\u51cf\u53bb\u5269\u4e0b\u7684\u548c<\/p>\n

<\/p>\n

1.6 \u996e\u6599\u4f9b\u8d27<\/p>\n

\u52a8\u6001\u89c4\u5212<\/p>\n

\u8d2a\u5fc3<\/p>\n

\u53c2\u8003:http:\/\/blog.csdn.net\/lichaoyin\/article\/details\/<\/p>\n

\u52a8\u6001\u89c4\u5212\u601d\u8def\u57fa\u672c\u4e0a\u662f\u80cc\u5305\u95ee\u9898<\/p>\n

\u8d2a\u5fc3\u7b97\u6cd5\u5229\u7528\u5230\u4e86\u8fdb\u5236\u5206\u89e3,\u5c06\u5bb9\u91cf\u4ee5\u4e8c\u8fdb\u5236\u770b\u5f85,\u8bbe\u8ba1\u6570\u636e\u7ed3\u6784:\u6bcf\u4e00\u4f4d\u540e\u6709\u4e00\u6761\u6700\u5927\u503c\u94fe\u8868,\u7b97\u6cd5:\u4ece\u4f4e\u4f4d\u5230\u9ad8\u4f4d,\u8be5\u4f4d\u9700\u8981\u5bb9\u91cf\u586b\u5145\u65f6\u5c31\u4ece\u6bcf\u4e00\u4f4d\u540e\u7684\u6709\u5e8f\u94fe\u8868\u4e2d\u5f97\u5230\u6ee1\u610f\u5ea6\u6700\u5927\u7684\u82e5\u5e72\u5bb9\u91cf\u76f8\u52a0,\u8ba1\u7b97\u4e4b\u524d\u5148\u5c06\u4e0a\u4e00\u4e2a\u4f4e\u4f4d\u7684\u6700\u5927\u503c\u5408\u5e76\u5230\u65b0\u7684\u94fe\u8868\u4e2d(\u6709\u4e9b\u7c7b\u4f3c\u54c8\u592b\u66fc\u6811\u7684\u6784\u9020\u8fc7\u7a0b?)<\/p>\n

<\/p>\n

1.7 \u5149\u5f71\u5207\u5272\u95ee\u9898<\/p>\n

\u89e3\u6cd5\u4e00:\u5206\u6790\u51fa\u6bcf\u589e\u52a0\u4e00\u76f4\u7ebf,\u5982\u679c\u589e\u52a0m\u4e2a\u4ea4\u70b9,\u90a3\u4e48\u8be5\u76f4\u7ebf\u88ab\u65b0\u589e\u52a0\u7684m\u4e2a\u4ea4\u6218\u5206\u6210m+1\u6bb5,\u6bcf\u4e00\u6bb5\u53c8\u4f1a\u5c06\u539f\u533a\u57df\u5212\u6210\u4e24\u5757,\u4e8e\u662f\u65b0\u589e\u52a0\u4e86m+1\u5757<\/p>\n

\u5982\u679c\u6709n\u6761\u76f4\u7ebf,m\u4e2a\u4ea4\u70b9,\u90a3\u4e48\u533a\u57df\u6570\u4e3an+m+1,\u6c42\u89e3\u8fc7\u7a0b\u662f1+\u6c42\u548c(m0+1)=1+n\u6761\u76f4\u63a5\u7684\u5168\u90e8\u4ea4\u70b9\u548c+n=1+m+n  \/\/ \u56e0\u4e3a\u6bcf\u6b21\u589e\u52a0m0+1,n\u4e2a\u70b9\u6c42\u548c<\/p>\n

\u5207\u5272\u5757\u6570\u5148\u5c06\u6240\u6709\u70b9\u7684\u4ea4\u70b9\u6c42\u51fa\u6765,\u7136\u540e\u6392\u5e8f,\u9501\u5b9aAB\u4e4b\u95f4\u7684\u70b9(\u4e8c\u5206\u67e5\u627e),\u518d\u5229\u75281+n+m\u8ba1\u7b97\u51fa\u5757\u6570<\/p>\n

\u89e3\u6cd5\u4e8c:<\/p>\n

\u533a\u57df\u5185\u7684\u4ea4\u6218\u6570\u76ee\u7b49\u4e8e\u4e00\u4e2a\u8fb9\u754c\u4e0a\u4ea4\u70b9\u987a\u5e8f\u76f8\u5bf9\u53e6\u4e00\u4e2a\u8fb9\u754c\u4ea4\u70b9\u987a\u5e8f\u7684\u9006\u5e8f\u603b\u6570,\u6c42\u9006\u5e8f\u6570\u5229\u7528\u5206\u6cbb\u6cd5\u53ef\u4ee5\u4f18\u5316\u5230O(n*logn)<\/p>\n

\/\/ by zjerry \u8fd9\u4e2a\u8f6c\u6362\u8fc7\u7a0b\u6ca1\u5b8c\u5168\u7406\u89e3,\u4e3a\u4ec0\u4e48\u9006\u5e8f\u6570\u4f1a=\u4ea4\u70b9\u6570?<\/p>\n

<\/p>\n

1.8 \u5c0f\u98de\u7684\u7535\u68af\u8c03\u8bd5\u7b97\u6cd5<\/p>\n

\u5982\u4f55\u4eceO(N^2)\u4f18\u5316\u5230O(N)\u7684\u5173\u952e\u662f\u627e\u5230\u904d\u5386\u8fc7\u7a0b\u76f8\u90bb\u4e4b\u95f4\u7684\u589e\u51cf\u5173\u7cfb<\/p>\n

\u6269\u5c55\u95ee\u9898<\/p>\n

1\u4ecd\u7136\u7528\u4e66\u4e2d\u7684\u89e3\u6cd5\u4e8c,O(N)\u65f6\u95f4\u5185\u89e3\u51b3,<\/p>\n

2\/\/ by zjerry \u8fd8\u8981\u518d\u60f3\u60f3<\/p>\n

<\/p>\n

1.9 \u9ad8\u6548\u7387\u5730\u5b89\u6392\u89c1\u9762\u4f1a<\/p>\n

\u7f16\u7a0b\u4e4b\u7f8e----\u6269\u5c55\u95ee\u9898
http:\/\/www.cppblog.com\/flyinghearts\/archive\/2010\/08\/15\/123536.html <\/p>\n

\u539f\u95ee\u9898\u662fNP\u7684\u7ecf\u5178\u95ee\u9898 \u5730\u56fe\u7740\u8272<\/p>\n

\u6269\u5c55\u95ee\u9898:<\/p>\n

1.\u57fa\u4e8e\u65f6\u95f4\u8f74\u7684\u6d3b\u52a8\u5730\u70b9\u9009\u62e9\u95ee\u9898,\u7531\u4e8e\u53ef\u4ee5\u5411\u4e00\u7ef4\u65f6\u95f4\u8f74\u6295\u5f71,\u6240\u4ee5\u53ef\u4ee5\u4f7f\u7528\u8d2a\u5fc3\u7b97\u6cd5<\/p>\n

\u4e66\u4e2dO(N^2)\u89e3\u6cd5\u6ca1\u4ed4\u7ec6\u7406\u89e3(\u5e94\u8be5\u662f\u7c7b\u4f3c\u7740\u8272\u5224\u65ad\u662f\u5426\u5408\u7406\u7684\u7b97\u6cd5),<\/p>\n

\u4e3b\u8981\u7406\u89e3\u7b2c\u4e8c\u4e2a\u89e3\u6cd5:\u76f4\u63a5\u8ba1\u7b97\u67d0\u533a\u95f4\u6700\u5927\u91cd\u53e0\u6b21\u6570,\u5982\u679c\u5229\u7528\u8ba1\u6570\u6392\u5e8f+\u4e00\u6b21MAX\u503c\u626b\u63cf,\u53ef\u4ee5\u4f18\u5316\u5230O(N)  \/\/ by zjerry<\/p>\n

2.\u95ee\u9898\u7684\u524d\u63d0\u8fd8\u662f\u5728\u4f18\u5316\u603b\u7684\u65f6\u95f4\u57fa\u7840\u4e0a,\u56e0\u6b64\u53ea\u80fd\u539f\u95ee\u9898\u7684\u57fa\u7840\u4e0a\u6269\u5f20\u7ed3\u6784\u4ee5\u5b9e\u73b0\u96c6\u4e2d<\/p>\n

\u6211\u7684\u60f3\u6cd5\u662f,\u540c\u5b66\u5bf9\u89c1\u9762\u4f1a\u7684\u5174\u8da3\u5ea6\u53ef\u4ee5\u7406\u89e3\u4e3a\u56fe\u4e2d\u7684\u8fb9\u7684\u6743\u91cd,\u8ba9\u6bcf\u4e2a\u90fd\u96c6\u4e2d\u4e5f\u5c31\u662f\u603b\u4f53\u96c6\u4e2d<\/p>\n

\u9876\u70b9\u7740\u8272\u6570\u91cf\u8bbe\u8ba1\u597d\u540e,\u9876\u70b9\u8d77\u59cb\u65f6\u95f4\u6392\u5e8f,\u8d77\u59cb\u65f6\u95f4\u76f8\u540c\u5219\u6309\u7167\u4e0a\u4e00\u9876\u70b9\u4e0e\u6b32\u9009\u62e9\u9876\u70b9\u7684\u5174\u8da3\u5ea6\u6392\u5e8f,\u6700\u540e\u5f97\u5230\u7ed3\u679c<\/p>\n

<\/p>\n

1.10 \u53cc\u7ebf\u7a0b\u9ad8\u6548\u4e0b\u8f7d<\/p>\n

\/\/ by zjerry \u4fe1\u53f7\u91cf,\u4e92\u65a5\u9501<\/p>\n

\n



\n
<\/p>\n

1.11 NIM(1)\u4e00\u6392\u77f3\u5934\u7684\u6e38\u620f<\/p>\n

\u6ce8\u660eA\u5148\u53d6,B\u540e\u53d6<\/p>\n

\u6269\u5c55<\/p>\n

1.N=3K+1(K=0\uff0c1\uff0c2\uff0c\u2026\u2026\uff09\u65f6\u5148\u53d6\u8005A\u8f93\uff0c\u5176\u4f59\u60c5\u51b5N=3K,N=3K+2\u65f6\u5148\u53d6\u8005A\u8d62<\/span><\/p>\n

\u7f16\u7a0b\u4e4b\u7f8e----\u6269\u5c55\u95ee\u9898 <\/p>\n

http:\/\/hi.baidu.com\/hehehehello\/item\/4115b9151a2f29fd756a8487 <\/p>\n

2.N%(K+1)=0\u65f6\uff0c\u73a9\u5bb6B\u6709\u5fc5\u80dc\u7b56\u7565\uff0cN%(K+1)!=0\u65f6\uff0c\u73a9\u5bb6A\u6709\u5fc5\u80dc\u7b56\u7565\u3002<\/p>\n

\u5f53d=0\u65f6\uff0c\u65e0\u8bbaA\u53d6\u591a\u5c11\u4e2a\u77f3\u5934\uff0cB\u53d6\u76f8\u5e94\u7684\u77f3\u5934\uff0c\u4f7f\u5f97A\u548cB\u4e00\u8d77\u53d6(K+1)\u4e2a\u77f3\u5934\uff0c\u8fd9\u6837\u6700\u540e\u53d6\u5230\u77f3\u5934\u7684\u80af\u5b9a\u662f\u73a9\u5bb6B\u3002 <\/p>\n

<\/p>\n

1.12 NIM(2)\"\u62c8\"\u6e38\u620f\u5206\u6790<\/p>\n

\u6ce8\u660eA\u5148\u5206\u914d,B\u5148\u53d6,A\u540e\u53d6<\/p>\n

http:\/\/www.cnblogs.com\/yintingru\/archive\/2012\/08\/27\/2658483.html <\/p>\n

\u53d6\u77f3\u5934\u7684\u8fc7\u7a0b\u4e0e\u4e0a\u4e00\u6b21\u4ed6\u4eba\u53d6\u7684\u6570\u76ee\u59cb\u7ec8\u4fdd\u6301\u4e00\u4e2a\"\u5b89\u5168\u7684\u72b6\u6001\",\u5373\u53ef\u4ee5\u786e\u4fdd\u5b8c\u80dc,\u8fd9\u91cc\u5b89\u5168\u7684\u72b6\u6001\u662fXOR\u4e3a0<\/p>\n

\u6269\u5c55\u95ee\u9898<\/p>\n

1\u5982\u679c\u53d6\u5149\u8005\u8f93,\u5f53N=2,B\u5148\u53d6,A\u5fc5\u8f93,N>2,A\u5fc5\u80dc,\u53ea\u8981\u786e\u4fdd\u5806\u6570\u4e3a\u5947,\u4e2a\u6570\u4e5f\u4e3a\u5947\u5373\u53ef,N\u4e3a\u5947\u6570,\u5219\u5206\u914d(1,1,1,...),N\u4e3a\u5076\u6570,\u5219\u5206\u914d(N\/2,N\/2)<\/p>\n

2\u82e5\u662f\u5148\u53d6\u5149\u8005\u80dc,\u5219A\u4fdd\u6301\u5b89\u5168\u72b6\u6001\u4e3a\u6bcf\u6b21\u53d6\u8d70\u548c\u4e3aK+1(\u4e0e1.11\u6269\u5c55\u95ee\u9898\u7c7b\u4f3c),\u4e14\u6bcf\u5806\u7684\u4e2a\u6570\u4e3a>=2(\u5173\u952e\u662f\u53d6\u5230\u53ea\u5269\u4e0bK+1,K+2...K+K-1\u5806\u65f6\u7684\u6289\u62e9\u95ee\u9898\u4e0a)<\/p>\n

\/\/ by zjerry \u672a\u4ed4\u7ec6\u8ba4\u8bc1,\u5148\u5230\u8fd9\u91cc<\/p>\n

<\/p>\n

1.13 NIM(3)\u4e24\u5806\u77f3\u5934\u7684\u6e38\u620f<\/p>\n

\u6ce8\u610fA\u5148\u53d6, B\u540e\u53d6,AB\u53ef\u4ee5\u4e24\u5806\u4e2d\u5404\u62ff\u76f8\u7b49\u6570\u91cf\u7684\u77f3\u5934\u6216\u4ece\u4e00\u5806\u4e2d\u53d6\u8d70\u4efb\u610f<\/p>\n

http:\/\/www.cnblogs.com\/flyinghearts\/archive\/2011\/03\/22\/1991972.html <\/p>\n

\u6269\u5c55<\/p>\n

1.A\u5148\u53d6\u59cb\u7ec8\u6784\u9020\u4e0d\u5b89\u5168\u5c40\u9762\u7ed9B,\u5373\u53ef\u786e\u4fdd\u5fc5\u80dc(\u524d\u63d0\u662f\u521d\u59cb\u72b6\u6001\u4e3a\u5b89\u5168)<\/p>\n

2.NIM(4)<\/p>\n

http:\/\/blog.sina.com.cn\/s\/blog_7689f89d01017u6y.html <\/p>\n

http:\/\/episte.math.ntu.edu.tw\/articles\/mm\/mm_03_2_02\/index.html \/\/ by  zjerry \u53f0\u5927\u6570\u5b66\u7cfb\u7f51\u7ad9,\u5e0c\u671b\u4e24\u5cb8\u7edf\u4e00,\u7f51\u7ad9\u53ef\u4ee5\u6301\u4e45\u8bbf\u95ee <\/p>\n

<\/p>\n

1.14 \u8fde\u8fde\u770b\u6e38\u620f\u8bbe\u8ba1<\/p>\n

\u6269\u5c55\u95ee\u9898:<\/p>\n

1.\u7ef4\u62a4\u4efb\u610f\u4e24\u4e2a\u683c\u5b50\u7684\u6700\u77ed\u8def\u5f84\u7684\u4f18\u70b9\u662f,\u6bcf\u6b21\u5237\u65b0\u6700\u77ed\u8def\u5f84\u6570\u636e\u540e\u90fd\u80fd\u8fc5\u901f\u5224\u65ad,\u4f46\u5237\u65b0\u6570\u636e\u7684\u8fc7\u7a0b\u4f1a\u6bd4\u8f83\u9ebb\u70e6,\u56e0\u4e3a\u8fde\u8fde\u770b\u6d88\u53bb\u540e\u7275\u626f\u7684\u683c\u5b50\u5e76\u4e0d\u80fd\u7acb\u5373\u786e\u5b9a\u51fa\u6765,\u5f88\u5927\u53ef\u80fd\u8981\u7ef4\u62a4\u5237\u65b0\u6240\u6709\u683c\u5b50,\u5219N*O(N)\u590d\u6742\u5ea6,\u6548\u7387\u4e0d\u4e00\u5b9a\u9ad8,<\/p>\n

\u6e38\u620f\u4e2d\u662f\u5426\u7528\u70b9\u51fb\u89e6\u53d1\u7684\u8303\u56f4\u4fee\u6539\u8fd8\u662f\u5168\u5c40\u7ef4\u62a4\u6570\u636e\u4fee\u6539,\u8fd9\u7c7b\u95ee\u9898\u7c7b\u4f3c\u4e8e\u52a8\u6001\u67e5\u627e\u6811\u5982\u7ea2\u9ed1\u6811,\u4e8c\u53c9\u5806,\u80fd\u5426\u5728O(logn)\u53ef\u63a5\u53d7\u7684\u65f6\u95f4\u8303\u56f4\u5185\u89e3\u51b3\u95ee\u9898<\/p>\n

2.\u6bcf\u6267\u884c\u5b8c\u4e00\u6b65\u4e0b\u68cb\u64cd\u4f5c\u540e,\u7528\u67d0\u79cd\u6570\u636e\u7ed3\u6784\u4fdd\u5b58\u5f53\u524d\u68cb\u5c40,\u5982\u538b\u7f29\u77e9\u9635,\u90bb\u63a5\u77e9\u9635,\u4f4d\u56fe\u7b49<\/p>\n

<\/p>\n

1.15 \u6784\u9020\u6570\u72ec<\/p>\n

\u7f16\u7a0b\u4e4b\u7f8e----\u6269\u5c55\u95ee\u9898 <\/p>\n

\u6269\u5c55\u95ee\u9898:<\/p>\n

\u5982\u4f55\u8868\u793a\u684c\u9762\u7a0b\u5e8f\u4e2d\u7684\u7a97\u53e3\/\u6309\u94ae\/\u63a7\u4ef6?\/\/ by zjerry \u6211\u4e00\u822c\u60f3\u5230\u7684\u662f\u5236\u5b9a\u5408\u7406\u7684\u5750\u6807\u7cfb,\u5982\u53f3x\u4e0by\u5916z,\u7136\u540e\u6bcf\u4e2a\u7a97\u53e3\u7684\u5c5e\u6027\u6709\u5de6\u4e0a\u89d2\u5750\u6807xy,\u957flength,\u5bbdwidth,z\u8f74z-order,\u80fd\u5426\u70b9\u51fbclickable,\u6027\u8d28(window,button,widget,etc)<\/p>\n

<\/p>\n

1.16 24\u70b9\u6e38\u620f<\/p>\n

\u7f16\u7a0b\u4e4b\u7f8e----\u6269\u5c55\u95ee\u9898 <\/p>\n

\u7f16\u7a0b\u4e4b\u7f8e----\u6269\u5c55\u95ee\u9898 <\/p>\n

http:\/\/www.cppblog.com\/flyinghearts\/archive\/2010\/08\/01\/121907.html <\/p>\n

http:\/\/www.cppblog.com\/flyinghearts\/archive\/2010\/08\/15\/123531.html <\/p>\n

\u89e3\u6cd5\u4e00:\u7a77\u4e3e\u9012\u5f52   \u4f18\u5316:\u526a\u679d,\u52a0\u6cd5\u548c\u4e58\u6cd5\u6ee1\u8db3\u4ea4\u6362\u5f8b,swap\u4f7fA>B\u6216A<B\u6765\u8fdb\u884c\u52a0\u4e58\u6cd5\u7684\u8ba1\u7b97<\/p>\n

\u89e3\u6cd5\u4e8c:\u96c6\u5408\u7684\u5206\u6cbb\u6c42\u89e3  \u4f18\u5316:\u6700\u540e\u4e00\u6b21\u4e24\u4e2a\u5b50\u96c6\u5408\u5e76\u76f4\u63a5\u8ba1\u7b97\u5224\u65ad\u662f\u542624\u70b9,\u4e0d\u7528\u518d\u8fdb\u884c\u96c6\u5408\u5408\u5e76\u540e\u518d\u5224\u65ad;\u4f9d\u7167\u89e3\u6cd5\u4e00,\u6bcf\u6b21\u53d6\u4e24\u4e2a\u6570\u8ba1\u7b97\u7136\u540e\u5408\u5e76\u96c6\u5408(\u6309\u4e66\u4e2d\u6bcf\u6b21\u63091,n-1\u6765\u5206\u89e3\u96c6\u5408,\u5206\u89e3\u96c6\u5408\u7684\u8fc7\u7a0b\u592a\u591a)<\/p>\n

<\/p>\n

1.17 \u4fc4\u7f57\u65af\u65b9\u5757\u6e38\u620f<\/p>\n

\u6269\u5c55\u95ee\u9898<\/p>\n

1.\u9700\u8981DFS\u8bb0\u5f55\u79fb\u52a8\u8def\u5f84<\/p>\n

2.OFFSETY\u589e\u52a02\u683c,\u5219OFFSETX\u7684\u5224\u65ad\u8303\u56f4\u51cf\u5c113<\/p>\n

3.\u4fc4\u7f57\u65af\u5e7f\u573a\u662f\u6d88\u9664\u7c7b\u6e38\u620f,\u4f18\u5148\u8003\u8651\u6d88\u9664(\u4f7f\u6e38\u620f\u66f4\u8f7b\u677e),\u5982\u6dfb\u52a0\u5b50\u5f39\u65b9\u5757,\u6dfb\u52a0\u7206\u70b8\u65b9\u5757,\u6dfb\u52a0\u6d88\u9664\u65b9\u5757;\u518d\u8003\u8651\u589e\u957f(\u4f7f\u6e38\u620f\u66f4\u56f0\u96be),\u5982\u6dfb\u52a0\u53d8\u5f62\u65b9\u5757,\u6dfb\u52a0\u79fb\u52a8\u52a0\u901f,\u6dfb\u52a0\u4e0b\u843d\u540e\u7684\u65b9\u5757\u4f1a\u81ea\u52a8\u5411\u4e0a\u589e\u957f,\u4e14\u5e26\u5c0f\u6d1e,\u81ea\u52a8\u5de6\u53f3\u5faa\u73af,\u521d\u59cb\u5e26\u6709\u5c0f\u6d1e\u7684\u5c42\u6b21,<\/p>\n

\u975e\u6e38\u620f\u529f\u80fd\u4e0a\u7684\u6269\u5c55\u53ef\u4ee5\u6709:\u79ef\u5206\u793e\u4ea4\u6392\u884c\u529f\u80fd,\u4e8c\u4ebaPK,\u5728\u7ebfPK,\u4e14PK\u5e26\u6709\u6218\u6597\u6a21\u5f0f,A\u65b9\u6d88\u9664\u9020\u6210B\u65b9\u589e\u957f<\/p>\n

\u626b\u96f7\u6e38\u620f\u662f\u5224\u65ad\u7c7b\u6e38\u620f,\u4f18\u5148\u8003\u8651\u964d\u4f4e\u96be\u5ea6,\u5982\u589e\u52a0\u63d0\u793a,\u51cf\u5c11\u96f7\u6570,\u518d\u8003\u8651\u589e\u52a0\u96be\u5ea6,\u5982\u53ef\u6539\u53d8\u683c\u5b50\u6570\u76ee,\u53ef\u8c03\u6574\u96f7\u6570,\u65f6\u95f4\u7f29\u77ed,\u96f7\u6709\u8f7b\u91cd\u7f13\u6025\u7684\u7b49\u7ea7,<\/p>\n

\u975e\u6e38\u620f\u529f\u80fd\u4e0a\u7684\u6269\u5c55\u79ef\u5206\u793e\u4ea4\u6392\u884c,\u4e8c\u4ebaPK,\u4e92\u76f8\u8bbe\u7f6e\u5bf9\u65b9\u7684\u96f7\u533a\u7b49<\/p>\n

<\/p>\n

1.18 \u6316\u96f7\u6e38\u620f<\/p>\n

\u53c2\u8003\uff1a<\/p>\n

http:\/\/blog.csdn.net\/wuyuegb2312\/article\/details\/ <\/p>\n

\u95ee\u98981<\/p>\n

\u9700\u8981\u5148\u89e3\u51b3\u95ee\u98982<\/p>\n

\u95ee\u98982<\/p>\n

1.\u6839\u636e\u5df2\u6709\u6570\u5b57\u5c06\u786e\u5b9a\u6709\u96f7\u548c\u65e0\u96f7\u7684\u5730\u533a\u6807\u8bb0\u51fa\u6765\uff0c\u7136\u540e\u5c06\u786e\u5b9a\u6709\u96f7\u76848\u90bb\u533a\u8ba1\u6570-1,\u6e05\u9664\u8be5\u5757\uff0c\u5c06\u786e\u5b9a\u65e0\u96f7\u76848\u90bb\u533a\u8ba1\u6570+1,\u6e05\u9664\u8be5\u5757\uff0c\u4f9d\u6b21\u89e3\u51b3\u51fa\u5df2\u70b9\u51fa\u533a\u57df\u7684\u90bb\u533a<\/p>\n

2.\u6b65\u9aa41\u89e3\u51b3\u540e\uff0c\u53ef\u786e\u5b9a\u96f7\u6570\u5df2\u77e5\uff0c\u7136\u540e\u5229\u7528\u5df2\u77e5\u533a\u57df\u76f8\u4ea4\u7684\u7ed3\u5408\u70b9\u6765\u5212\u5206\u5b50\u96f7\u533a\uff0c\u518d\u6839\u636e\u53e4\u5178\u6982\u7387\u8ba1\u7b97\u5b50\u96f7\u533a\u7684\u6bcf\u4e2a\u70b9\u7684\u6982\u7387<\/p>\n

\u53c2\u80034.11 \u626b\u96f7\u6e38\u620f\u7684\u6982\u7387<\/p>\n

<\/p>\n

2.1\u6c42\u4e8c\u8fdb\u5236\u4e2d1\u7684\u4e2a\u6570<\/p>\n

\u89e3\u6cd5:
1,v\u6a212\u7684\u503c\u662f1\u5219++;
2,v\u53f3\u79fb(\u76f8\u5f53\u4e8e\u96642),\u7136\u540e\u4e0e0x1\u4e0e\u8fd0\u7b97(\u4e0e\u4e0a\u4e00\u89e3\u6cd5\u601d\u8def\u4e00\u81f4);
3,v\u4e0ev-1\u8fdb\u884c\u4e0e\u8fd0\u7b97,\u5c06\u6d88\u53bb\u6700\u53f3\u8fb9\u76841,\u5faa\u73af\u8fdb\u884c\u4e0b\u53bb,\u65f6\u95f4\u590d\u6742\u5ea6\u53ea\u6709O(n) n=1\u7684\u4e2a\u6570;
4,\u67e5\u8868\u7684\u590d\u6742\u5ea6\u4e3aO(1),\u4e0d\u8fc7\u8981\u8003\u8651\u5efa\u8868\u7684\u65f6\u95f4
\u9488\u5bf9\u8be5\u95ee\u9898,\u6709\u89c4\u5f8b\u8fdb\u884c\u5feb\u901f\u5efa\u8868:
5,\u6839\u636e\u5947\u5076\u6027\u6765\u5206\u6790\uff0c\u5bf9\u4e8e\u4efb\u610f\u4e00\u4e2a\u6b63\u6574\u6570n
1.\u5982\u679c\u5b83\u662f\u5076\u6570\uff0c\u90a3\u4e48n\u7684\u4e8c\u8fdb\u5236\u4e2d1\u7684\u4e2a\u6570\u4e0en\/2\u4e2d1\u7684\u4e2a\u6570\u662f\u76f8\u540c\u7684\uff0c\u6bd4\u59824\u548c2\u7684\u4e8c\u8fdb\u5236\u4e2d\u90fd\u6709\u4e00\u4e2a1\uff0c6\u548c3\u7684\u4e8c\u8fdb\u5236\u4e2d\u90fd\u6709\u4e24\u4e2a1\u3002\u4e3a\u5565\uff1f\u56e0\u4e3an\u662f\u7531n\/2\u5de6\u79fb\u4e00\u4f4d\u800c\u6765\uff0c\u800c\u79fb\u4f4d\u5e76\u4e0d\u4f1a\u589e\u52a01\u7684\u4e2a\u6570\u3002
2.\u5982\u679cn\u662f\u5947\u6570\uff0c\u90a3\u4e48n\u7684\u4e8c\u8fdb\u5236\u4e2d1\u7684\u4e2a\u6570\u662fn\/2\u4e2d1\u7684\u4e2a\u6570+1\uff0c\u6bd4\u59827\u7684\u4e8c\u8fdb\u5236\u4e2d\u6709\u4e09\u4e2a1\uff0c7\/2 = 3\u7684\u4e8c\u8fdb\u5236\u4e2d\u6709\u4e24\u4e2a1\u3002\u4e3a\u5565\uff1f\u56e0\u4e3a\u5f53n\u662f\u5947\u6570\u65f6\uff0cn\u76f8\u5f53\u4e8en\/2\u5de6\u79fb\u4e00\u4f4d\u518d\u52a01\u3002<\/p>\n

http:\/\/blog.csdn.net\/justpub\/article\/details\/
http:\/\/www.cnblogs.com\/graphics\/archive\/2010\/06\/21\/1752421.html <\/span> <\/p>\n

6.\u4e8c\u5206\u6cd5,\u6216\u4e09\u4e2a\u4e00\u7ec4\u7684\u4f4d\u64cd\u4f5c\u65b9\u6cd5<\/p>\n

SSE4.2:POPCNT\u6307\u4ee4\u7b97\u6cd5
http:\/\/en.wikipedia.org\/wiki\/Hamming_weight <\/p>\n

HAKMEM\u7b97\u6cd5<\/p>\n

   1:  int Count(unsigned x) {
\n
   2:     unsigned n;    
   3:      
   4:     n = (x >> 1) & 0;    
   5:     x = x - n;   
   6:     n = (n >> 1) & 0;   
   7:     x = x - n;    
   8:     x = (x + (x >> 3)) & 0;   
   9:     x = modu(x, 63);  
   10:     return x;   
   11:  }  <\/p>\n

\u6216\u5199\u6210<\/p>\n

\n

\n
\n
\n [html]<\/strong>  view plain copy <\/p>\n
\n <\/div>\n<\/p><\/div>\n<\/p><\/div>\n
    \n
  1. int BitCount5(unsigned int n)   <\/span><\/span><\/li>\n
  2. {  <\/span><\/li>\n
  3.     unsigned int tmp<\/span> = <\/span>n<\/span> - ((n <\/span>><\/span>><\/span>1) &0) - ((n <\/span>><\/span>><\/span>2) &0);  <\/span><\/span><\/li>\n
  4.     return ((tmp + (tmp ><\/span>><\/span>3)) &0) %63;  <\/span><\/span><\/li>\n
  5. }  <\/span><\/li>\n<\/ol>\n<\/div>\n



    \n
    <\/p>\n

    \n

    \u6269\u5c55<\/p>\n

    \u95ee\u9898\u4e00\u662f\u95ee32\u4f4d\u6574\u578b\u5982\u4f55\u5904\u7406\uff0c\u7528HAKMEM\u7b97\u6cd5,\u5efa\u8868,\u6216\u76f8\u4e0e\u7684\u65b9\u6cd5\u90fd\u5408\u9002\u3002<\/p>\n

    \u95ee\u9898\u4e8c\u662f\u7ed9\u5b9a\u4e24\u4e2a\u6574\u6570A\u548cB\uff0c\u95eeA\u548cB\u6709\u591a\u5c11\u4f4d\u662f\u4e0d\u540c\u7684\u3002<\/p>\n

    \u53ea\u8981\u5148\u7b97\u51faA\u548cB\u7684\u5f02\u6216\u7ed3\u679c\uff0c\u7136\u540e\u6c42\u8fd9\u4e2a\u503c\u4e2d1\u7684\u4e2a\u6570\u5c31\u884c\u4e86\u3002<\/p>\n

    \n

    \u8fd9\u4e2a\u95ee\u9898\u5176\u5b9e\u5c31\u662f\u65701\u95ee\u9898\u591a\u4e86\u4e00\u4e2a\u6b65\u9aa4\uff0c\u53ea\u8981\u5148\u7b97\u51faA\u548cB\u7684\u5f02\u6216\u7ed3\u679c\uff0c\u7136\u540e\u6c42\u8fd9\u4e2a\u503c\u4e2d1\u7684\u4e2a\u6570\u5c31\u884c\u4e86\u3002 <\/p>\n

    <\/p>\n

    2.2\u4e0d\u8981\u88ab\u9636\u4e58\u5413\u5012<\/p>\n

    1.\u6c42N!\u672b\u5c3e\u6709\u591a\u5c11\u4e2a0
    \u89e3\u6cd5\uff1a
    \u6c42\u8d28\u56e0\u65705\u7684\u4e2a\u6570
    \u5176\u4e2d\u6709\u516c\u5f0fN!\u9636\u4e58\u4e2d\u542b\u6709K\u7684\u8d28\u56e0\u6570\u4e2a\u6570 Z=[N\/K]+[N\/K^2]+[N\/K^3]+...
    2.\u6c42N!\u4e8c\u8fdb\u5236\u6700\u4f4e\u4f4d1\u7684\u4f4d\u7f6e
    \u89e3\u6cd5\uff1a\u540c\u4e0a
    \u6c42\u8d28\u56e0\u65702\u7684\u4e2a\u6570+1\uff08\u672b\u5c3e\u6709\u591a\u5c11\u4e2a0\u518d+1\u4f4d\u5c31\u662f\u6700\u4f4e\u4f4d1\u7684\u4f4d\u7f6e\uff09
    \u540c\u6837\u4f7f\u7528\u516c\u5f0fZ
    \u89e3\u6cd52\uff1a\u516c\u5f0fZ\u8f6c\u5316\u4e8c\u8fdb\u5236\u540e\u53ef\u4ee5\u6362\u7b97\uff1dN\u51cf\u53bbN\u7684\u4e8c\u8fdb\u5236\u4e2d1\u7684\u4e2a\u6570 <\/p>\n

    \u76f8\u5173\u9898\u76ee:<\/p>\n

    \u7ed9\u5b9a\u6574\u6570,\u5224\u65ad\u662f\u5426\u662f2\u7684\u65b9\u5e42<\/p>\n

    \u5373n>0&&(n&(n-1)==0)  \/\/ \u8be5\u6570\u4e8c\u8fdb\u5236\u8868\u793a\u6cd5\u53ea\u6709\u4e00\u4e2a1<\/p>\n

    <\/p>\n

    2.3\u5bfb\u627e\u53d1\u5e16\u6c34\u738b<\/p>\n

    \u5bfb\u627e\u53ef\u91cd\u590d\u6570\u636e\u4e2d\u51fa\u73b0\u6b21\u6570\u8d85\u8fc7\u4e00\u534a\u7684\u9879
    http:\/\/www.cnblogs.com\/sooner\/archive\/2013\/04\/02\/2996589.html
    \u89e3\u6cd5\u4e00\uff1a\u5148\u6392\u5e8f\uff0c\u7136\u540eN\/2\u7684\u9879\u5373\u4e3a\u6240\u6c42
    \u89e3\u6cd5\u4e8c\uff1a\u6bcf\u6b21\u53bb\u9664\u4e24\u4e2a\u4e0d\u540cID\u9879\uff0c\u6700\u540e\u5f97\u5230\u7684\u5373\u4e3a\u6240\u6c42\uff0cO(N) <\/p>\n

    \n

    \n
    \n
    \n [cpp]<\/strong>  view plain copy <\/p>\n
    \n <\/div>\n<\/p><\/div>\n<\/p><\/div>\n
      \n
    1. int<\/span> find(<\/span>int<\/span> ID[], <\/span>int<\/span> n)  <\/span><\/span><\/li>\n
    2. {  <\/span><\/li>\n
    3.     int<\/span> nTimes = 0, i, candidate;  <\/span><\/span><\/li>\n
    4.        <\/span><\/li>\n
    5.     for<\/span>(i = 0; i < n;i++)  <\/span><\/span><\/li>\n
    6.     {  <\/span><\/li>\n
    7.           if<\/span>(nTimes == 0)  <\/span><\/span><\/li>\n
    8.           {  <\/span><\/li>\n
    9.               candidate = ID[i];  <\/span><\/li>\n
    10.               nTimes = 1;  <\/span><\/li>\n
    11.           }  <\/span><\/li>\n
    12.           else<\/span>  <\/span><\/span><\/li>\n
    13.           {  <\/span><\/li>\n
    14.               if<\/span>(candidate == ID[i])  <\/span><\/span><\/li>\n
    15.               {  <\/span><\/li>\n
    16.                   nTimes++;  <\/span><\/li>\n
    17.               }  <\/span><\/li>\n
    18.               else<\/span>  <\/span><\/span><\/li>\n
    19.               {  <\/span><\/li>\n
    20.                   nTimes--;  <\/span><\/li>\n
    21.               }  <\/span><\/li>\n
    22.           }  <\/span><\/li>\n
    23.     }  <\/span><\/li>\n
    24.     return<\/span> candidate;  <\/span><\/span><\/li>\n
    25. }  <\/span><\/li>\n<\/ol>\n<\/div>\n

      \u7f3a\u70b9\u662f\u65e0\u6cd5\u540c\u65f6\u5f97\u5230\u8be5\u9879\u6b21\u6570<\/span>
      \n

      \n\u89e3\u6cd5\u4e09\uff1aHASH\u7edf\u8ba1\uff0c\u7a7a\u95f4\u590d\u6742\u5ea6O(N)\uff0c\u89e3\u6cd5\u4e8c\u662fO(1)<\/span>
      \n
      <\/p>\n

      \n

      \u6269\u5c55\u95ee\u9898
      \u5df2\u77e5\u6709M\u4e2a\u53d1\u5e16\u91cf\u57281\/(M+1)\u4e2a\u4ee5\u4e0a\u7684ID<\/p>\n

      \u4f8b\u5b50\uff1a
      \u6269\u5c55\u9898\uff0c\u9898\u76ee\u5982\u4e0b\uff1a
      \u968f\u7740Tango\u7684\u53d1\u5c55\uff0c\u7ba1\u7406\u5458\u53d1\u73b0\uff0c\u201c\u8d85\u7ea7\u6c34\u738b\u201d\u6ca1\u6709\u4e86\u3002\u7edf\u8ba1\u7ed3\u679c\u8868\u660e\uff0c\u67093\u4e2a\u53d1\u5e16\u5f88\u591a\u7684ID\uff0c\u4ed6\u4eec\u7684\u53d1\u5e16\u6570\u76ee\u90fd\u8d85\u8fc7\u4e86\u5e16\u5b50\u603b\u6570\u76eeN\u76841\/4\u3002\u4f60\u80fd\u4ece\u53d1\u5e16ID\u5217\u8868\u4e2d\u5feb\u901f\u627e\u51fa\u4ed6\u4eec\u7684ID\u5417\uff1f<\/p>\n

      \u540c\u65f6\u5220\u96644\u4e2a\u4e0d\u540c\u7684ID\u540e\uff0c\u5269\u4f59\u6570\u636e\u4e2d3\u4e2a\u591a\u6570id\u4ecd\u7136\u662f\u591a\u6570ID\u3002<\/p>\n

      \u4e0a\u9898\u53ea\u9700\u8981\u4e00\u4e2a\u7ed3\u679c\uff0c\u800c\u73b0\u5728\u9700\u89813\u4e2a\u7ed3\u679c\uff0c\u4e0a\u9898\u7528\u5230\u7684nTimes\uff0c\u4e5f\u5e94\u6539\u4e3a3\u4e2a\u8ba1\u6570\u5668\u3002\u73b0\u5728\u6211\u4eec\u9700\u89813\u4e2a\u53d8\u91cf\u6765\u8bb0\u5f55\u5f53\u524d\u904d\u5386\u8fc7\u76843\u4e2a\u4e0d\u540c\u7684ID\uff0c\u800cnTimes\u76843\u4e2a\u5143\u7d20\u5206\u522b\u5bf9\u5e94\u5f53\u524d\u904d\u5386\u8fc7\u76843\u4e2aID\u51fa\u73b0\u7684\u4e2a\u6570\u3002\u5982\u679c\u904d\u5386\u4e2d\u6709\u67d0\u4e2aID\u4e0d\u540c\u4e8e\u8fd93\u4e2a\u5f53\u524dID\uff0c\u6211\u4eec\u5c31\u5224\u65ad\u5f53\u524d3\u4e2aID\u662f\u5426\u6709\u67d0\u4e2a\u7684nTimes\u4e3a0\uff0c\u5982\u679c\u6709\uff0c\u90a3\u8fd9\u4e2a\u65b0\u904d\u5386\u7684ID\u5c31\u53d6\u800c\u4ee3\u4e4b\uff0c\u5e76\u8d4b1\u4e3a\u5b83\u7684\u904d\u5386\u6570\uff08\u5373nTimes\u51cf1\uff09\uff0c\u5982\u679c\u5f53\u524d3\u4e2aID\u7684nTimes\u7686\u4e0d\u4e3a0\uff0c\u52193\u4e2aID\u7684nTimes\u7686\u51cf\u53bb1\u3002 <\/p>\n

      \n

      \n
      \n
      \n [cpp]<\/strong>  view plain copy <\/p>\n
      \n <\/div>\n<\/p><\/div>\n<\/p><\/div>\n
        \n
      1. #include <iostream><\/span>  <\/span><\/span><\/li>\n
      2.   <\/span><\/li>\n
      3. using<\/span> <\/span>namespace<\/span> std;  <\/span><\/span><\/li>\n
      4.   <\/span><\/li>\n
      5. int<\/span> candidate[3];  <\/span><\/span><\/li>\n
      6. int<\/span> count[3] = {0};  <\/span><\/span><\/li>\n
      7.   <\/span><\/li>\n
      8. int<\/span> input[100];  <\/span><\/span><\/li>\n
      9. int<\/span> num = 0;  <\/span><\/span><\/li>\n
      10.   <\/span><\/li>\n
      11. int<\/span> main()  <\/span><\/span><\/li>\n
      12. {  <\/span><\/li>\n
      13.     cout<<\"please input\"<\/span><<endl;  <\/span><\/span><\/li>\n
      14.     int<\/span> t;  <\/span><\/span><\/li>\n
      15.     while<\/span>(cin>>t)  <\/span><\/span><\/li>\n
      16.     {  <\/span><\/li>\n
      17.         if<\/span> (t == -1)  <\/span><\/span><\/li>\n
      18.             break<\/span>;  <\/span><\/span><\/li>\n
      19.         input[num++] = t;  <\/span><\/li>\n
      20.     }  <\/span><\/li>\n
      21.   <\/span><\/li>\n
      22.     bool<\/span> flag = <\/span>false<\/span>;  <\/span><\/span><\/li>\n
      23.   <\/span><\/li>\n
      24.     for<\/span> (<\/span>int<\/span> i = 0;i < num;i++)  <\/span><\/span><\/li>\n
      25.     {  <\/span><\/li>\n
      26.         flag = false<\/span>;  <\/span><\/span><\/li>\n
      27.         for<\/span> (<\/span>int<\/span> j = 0;j < 3;j++)  <\/span><\/span><\/li>\n
      28.         {  <\/span><\/li>\n
      29.             if<\/span> (count[j] == 0)  <\/span><\/span><\/li>\n
      30.             {  <\/span><\/li>\n
      31.                 continue<\/span>;  <\/span><\/span><\/li>\n
      32.             }  <\/span><\/li>\n
      33.             if<\/span> (candidate[j] == input[i])  <\/span><\/span><\/li>\n
      34.             {  <\/span><\/li>\n
      35.                 count[j]++;  <\/span><\/li>\n
      36.                 flag = true<\/span>;  <\/span><\/span><\/li>\n
      37.             }  <\/span><\/li>\n
      38.         }  <\/span><\/li>\n
      39.   <\/span><\/li>\n
      40.         if<\/span> (flag == <\/span>true<\/span>)  <\/span><\/span><\/li>\n
      41.         {  <\/span><\/li>\n
      42.             continue<\/span>;  <\/span><\/span><\/li>\n
      43.         }  <\/span><\/li>\n
      44.   <\/span><\/li>\n
      45.         for<\/span> (<\/span>int<\/span> j = 0;j < 3;j++)  <\/span><\/span><\/li>\n
      46.         {  <\/span><\/li>\n
      47.             if<\/span> (count[j] == 0)  <\/span><\/span><\/li>\n
      48.             {  <\/span><\/li>\n
      49.                 candidate[j] = input[i];  <\/span><\/li>\n
      50.                 count[j]++;  <\/span><\/li>\n
      51.                 flag = true<\/span>;  <\/span><\/span><\/li>\n
      52.                 break<\/span>;  <\/span><\/span><\/li>\n
      53.             }  <\/span><\/li>\n
      54.         }  <\/span><\/li>\n
      55.   <\/span><\/li>\n
      56.         if<\/span> (flag == <\/span>true<\/span>)  <\/span><\/span><\/li>\n
      57.         {  <\/span><\/li>\n
      58.             continue<\/span>;  <\/span><\/span><\/li>\n
      59.         }  <\/span><\/li>\n
      60.   <\/span><\/li>\n
      61.         for<\/span> (<\/span>int<\/span> j = 0;j < 3;j++)  <\/span><\/span><\/li>\n
      62.         {  <\/span><\/li>\n
      63.             count[j]--;  <\/span><\/li>\n
      64.         }  <\/span><\/li>\n
      65.   <\/span><\/li>\n
      66.     }  <\/span><\/li>\n
      67.   <\/span><\/li>\n
      68.     cout<<count[0]<<\" \"<\/span><<count[1]<<<\/span>\" \"<\/span><<count[2]<<endl;  <\/span><\/span><\/li>\n
      69.     cout<<candidate[0]<<\" \"<\/span><<candidate[1]<<<\/span>\" \"<\/span><<candidate[2]<<endl;  <\/span><\/span><\/li>\n
      70. }  <\/span><\/li>\n
      71.   <\/span><\/li>\n
      72. \u6216  <\/span><\/li>\n
      73. void<\/span> Find(Type* ID, <\/span>int<\/span> N,Type candidate[3])  <\/span><\/span><\/li>\n
      74. {  <\/span><\/li>\n
      75.     Type ID_NULL;\/\/\u5b9a\u4e49\u4e00\u4e2a\u4e0d\u5b58\u5728\u7684ID<\/span>  <\/span><\/span><\/li>\n
      76.     int<\/span> nTimes[3], i;  <\/span><\/span><\/li>\n
      77.     nTimes[0]=nTimes[1]=nTimes[2]=0;  <\/span><\/li>\n
      78.     candidate[0]=candidate[1]=candidate[2]=ID_NULL;  <\/span><\/li>\n
      79.     for<\/span>(i = 0; i < N; i++)  <\/span><\/span><\/li>\n
      80.     {  <\/span><\/li>\n
      81.         if<\/span>(ID[i]==candidate[0])  <\/span><\/span><\/li>\n
      82.         {  <\/span><\/li>\n
      83.              nTimes[0]++;  <\/span><\/li>\n
      84.         }  <\/span><\/li>\n
      85.         else<\/span> <\/span>if<\/span>(ID[i]==candidate[1])  <\/span><\/span><\/li>\n
      86.         {  <\/span><\/li>\n
      87.              nTimes[1]++;  <\/span><\/li>\n
      88.         }  <\/span><\/li>\n
      89.         else<\/span> <\/span>if<\/span>(ID[i]==candidate[2])  <\/span><\/span><\/li>\n
      90.         {  <\/span><\/li>\n
      91.              nTimes[2]++;  <\/span><\/li>\n
      92.         }  <\/span><\/li>\n
      93.         else<\/span> <\/span>if<\/span>(nTimes[0]==0)  <\/span><\/span><\/li>\n
      94.         {  <\/span><\/li>\n
      95.              nTimes[0]=1;  <\/span><\/li>\n
      96.              candidate[0]=ID[i];  <\/span><\/li>\n
      97.         }  <\/span><\/li>\n
      98.         else<\/span> <\/span>if<\/span>(nTimes[1]==0)  <\/span><\/span><\/li>\n
      99.         {  <\/span><\/li>\n
      100.              nTimes[1]=1;  <\/span><\/li>\n
      101.              candidate[1]=ID[i];  <\/span><\/li>\n
      102.         }  <\/span><\/li>\n
      103.         else<\/span> <\/span>if<\/span>(nTimes[2]==0)  <\/span><\/span><\/li>\n
      104.         {  <\/span><\/li>\n
      105.              nTimes[2]=1;  <\/span><\/li>\n
      106.              candidate[2]=ID[i];  <\/span><\/li>\n
      107.         }  <\/span><\/li>\n
      108.         else<\/span>  <\/span><\/span><\/li>\n
      109.         {  <\/span><\/li>\n
      110.              nTimes[0]--;  <\/span><\/li>\n
      111.              nTimes[1]--;  <\/span><\/li>\n
      112.              nTimes[2]--;  <\/span><\/li>\n
      113.          }  <\/span><\/li>\n
      114.     }  <\/span><\/li>\n
      115.     return<\/span>;  <\/span><\/span><\/li>\n
      116. }  <\/span><\/li>\n<\/ol>\n<\/div>\n



        \n2.4 1\u7684\u6570\u76ee<\/span> <\/p>\n

        \n

        \u95ee\u9898\u4e00<\/p>\n

        1\u5f53\u524d\u4f4d=0,\u5219\u5f53\u524d\u4f4d\u4e0a\u51fa\u73b01\u7684\u6570\u76ee=\u9ad8\u4f4d*R<\/p>\n

        2\u5f53\u524d\u4f4d=1,\u5219\u6570\u76ee=\u9ad8\u4f4d*R+(\u4f4e\u4f4d\u6570\u5b57+1)<\/p>\n

        3\u5f53\u524d\u4f4d>1,\u5219\u6570\u76ee=(\u9ad8\u4f4d+1)*R<\/p>\n

        \n

        \n
        \n
        \n [cpp]<\/strong>  view plain copy <\/p>\n
        \n <\/div>\n<\/p><\/div>\n<\/p><\/div>\n
          \n
        1. unsigned <\/span>long<\/span> Sumls(unsigned <\/span>long<\/span> n)  <\/span><\/span><\/li>\n
        2. {  <\/span><\/li>\n
        3.    unsigned long<\/span> iCount=0;  <\/span><\/span><\/li>\n
        4.    unsigned long<\/span> iFactor=1;  <\/span><\/span><\/li>\n
        5.    unsigned long<\/span> iLowerNum=0;  <\/span><\/span><\/li>\n
        6.    unsigned long<\/span> iCurrNum=0;  <\/span><\/span><\/li>\n
        7.    unsigned long<\/span> iHigherNum=0;  <\/span><\/span><\/li>\n
        8.   <\/span><\/li>\n
        9.    while<\/span>(n\/iFactor!=0)  <\/span><\/span><\/li>\n
        10.    {  <\/span><\/li>\n
        11.       iLowerNum=n-(n\/iFactor)*iFactor;  <\/span><\/li>\n
        12.       iCurrNum=(n\/iFactor)%10;  <\/span><\/li>\n
        13.       iHigherNum=n\/(iFactor*10);  <\/span><\/li>\n
        14.   <\/span><\/li>\n
        15.       switch<\/span>(iCurrNum)  <\/span><\/span><\/li>\n
        16.       {  <\/span><\/li>\n
        17.       case<\/span> 0:  <\/span><\/span><\/li>\n
        18.           iCount+=iHigherNum*iFactor;  <\/span><\/li>\n
        19.           break<\/span>;  <\/span><\/span><\/li>\n
        20.       case<\/span> 1:  <\/span><\/span><\/li>\n
        21.           iCount+=iHigherNum*iFactor+iLowerNum+1;  <\/span><\/li>\n
        22.           break<\/span>;  <\/span><\/span><\/li>\n
        23.       default<\/span>:  <\/span><\/span><\/li>\n
        24.           iCount+=(iHigherNum+1)*iFactor;  <\/span><\/li>\n
        25.           break<\/span>;  <\/span><\/span><\/li>\n
        26.         <\/span><\/li>\n
        27.       }  <\/span><\/li>\n
        28.       iFactor*=10;  <\/span><\/li>\n
        29.    }  <\/span><\/li>\n
        30.    return<\/span> iCount;  <\/span><\/span><\/li>\n
        31.   <\/span><\/li>\n
        32. }  <\/span><\/li>\n<\/ol>\n<\/div>\n

          \u95ee\u9898\u4e8c<\/span>
          \n

          \n\u603b\u7ed3\u89c4\u5f8b,\u7136\u540e\u4f30\u7b97\u51fa\u4e0a\u754cN=10^11,\u518d\u4ece\u4e0a\u754c\u5f00\u59cb\u8c03\u7528\u4e0a\u8ff0\u7b97\u6cd5,\u6c42\u5f97\u7b54\u6848<\/span> <\/p>\n

          \n

          <\/p>\n

          \u6269\u5c55<\/p>\n

          \u53c2\u8003:(\/\/ by zj \u6682\u65f6\u672a\u601d\u8003\u8fd9\u95ee\u9898)<\/p>\n

          \u7ed9\u5b9a\u4e8c\u8fdb\u5236\u6570N\uff0c\u5199\u4e0b\u4ece1\u5f00\u59cb\u5230N\u7684\u6240\u6709\u4e8c\u8fdb\u5236\u6570\uff0c\u6570\u4e00\u4e0b\u5176\u4e2d\u51fa\u73b0\u7684\u6240\u6709\u201c1\u201d\u7684\u4e2a\u6570\uff1a<\/p>\n

          \n \u3000\u3000\u3000\u3000\u3000f(1)=1\n<\/div>\n
          \n  
          \n   
          \n   
          \n   
          \n   
          \n  f(10)=10 (\u56e0\u4e3a01,10\uff0c\u6709\u4e24\u4e2a1)\n<\/div>\n
          \n  
          \n   
          \n   
          \n   
          \n   
          \n  f(11)=100 (\u56e001,10,11\uff0c\u6709\u56db\u4e2a1)\n<\/div>\n
          \n \u89e3\u7b54\uff1a\u8003\u8651f\uff081011\uff09\uff1a1,10,11,100,101,110,111,1000,1001,1010,1011\n<\/div>\n
          \n  
          \n   
          \n   
          \n  \u7b2c\u4e00\u4f4d\u4e0a\uff1a\u9ad8\u4f4d\u6570\u4e3a101\uff0c\u6bcf\u4e24\u4e2a\u6570\u5c31\u51fa\u73b0\u4e00\u4e2a1\uff0c\u5219\u51fa\u73b0101\u4e2a1\uff1b\u4e14current\u4f4d\u4e3a1\uff0c\u4f4e\u4f4d\u6570\u4e3a0\uff0c\u6240\u4ee55+1=6\n<\/div>\n
          \n  
          \n   
          \n   
          \n  \u7b2c\u4e8c\u4f4d\u4e0a\uff1a\u9ad8\u4f4d\u6570\u4e3a10\uff0c\u6bcf\u56db\u4e2a\u6570\u51fa\u73b0\u4e00\u4e2a1\uff0c\u5219\u51fa\u73b0\uff0810\uff09*2=4\u4e2a1\uff1b\u4e14current\u4f4d\u4e3a1\uff0c\u4f4e\u4f4d\u6570\u4e3a1\uff0c\u6240\u4ee54+1+1=6\n<\/div>\n
          \n  
          \n   
          \n   
          \n  \u7b2c\u4e09\u4f4d\uff1a\u9ad8\u4f4d\u6570\u4e3a1\uff0c\u51fa\u73b0\uff081\uff09*2^2=4\u4e2a1\uff1b\u4e14current\u4f4d\u4e3a0\uff0c\u4f4e\u4f4d\u6570\u4e3a11\uff1b\u6240\u4ee54+0=4\n<\/div>\n
          \n  
          \n   
          \n   
          \n  \u7b2c\u56db\u4f4d\uff1a\u9ad8\u4f4d\u6570\u4e3a0,\uff0ccurrent\u4f4d\u4e3a1\uff0c\u4f4e\u4f4d\u6570\u4e3a011\uff1b\u6240\u4ee5\u4e3a \u4f4e\u4f4d\u6570+1=4\n<\/div>\n
          \n  
          \n   
          \n   
          \n \n<\/div>\n
          \n  
          \n \u901a\u8fc7\u89c2\u5bdf\u53d1\u73b0\u5728 current==1 \u65f6\uff0c\u7b2cn\u4f4d\u4e0a\u51fa\u73b01\u7684\u6b21\u6570 = \u9ad8\u4f4d\u6570*2^n-1 +\u4f4e\u4f4d\u6570+1
          \n <\/p>\n
          \n  
          \n   
          \n   
          \n   
          \n   
          \n   
          \n   
          \n   
          \n  
          \n current==0 \u65f6\uff0c\u7b2cn\u4f4d\u4e0a\u51fa\u73b01\u7684\u6b21\u6570 = <\/span>
          \n \u9ad8\u4f4d\u6570*2^n-1<\/span>\n <\/div>\n<\/div>\n


          <\/p>\n

          \n

          2.5 \u5bfb\u627e\u6700\u5927\u7684K\u4e2a\u6570<\/p>\n

          \u5229\u7528\u7b80\u5355\u6392\u5e8f\u7b97\u6cd5\uff1a\u5192\u6ce1\u6392\u5e8f\uff0c\u9009\u62e9\u6392\u5e8f\uff0cO(N*K) <\/p>\n

          \u5229\u7528\u5feb\u901f\u6392\u5e8f\u7684\u9012\u5f52\u65b9\u6cd5,\u5224\u65ad\u6bcf\u6b21\u5feb\u6392\u540e\u7684K\u5de6\u53f3\u4e24\u8fb9\u6570\u7ec4\u5927\u5c0f <\/p>\n

          \u5bfb\u627e\u6700\u5927\u7684K\u4e2a\uff1d\u5bfb\u627e\u7b2cK\u5927\uff0c\u8fdb\u800c\u53ef\u4ee5\u6839\u636e\u6570\u7684\u672c\u8d28\u5927\u5c0f\u987a\u5e8f\u8fdb\u884c\u4e8c\u5206\u67e5\u627e\uff08\u6574\u6570\u7684\u8bdd\u53ef\u4ee5\u4ece\u4e8c\u8fdb\u5236\u89d2\u5ea6\u7406\u89e3\uff09
          \u90e8\u5206\u8f7d\u5165\u7684\u7b97\u6cd5\u53ef\u4ee5\u8003\u8651\u6bcf\u6b21\u5c06\u6700\u5927\u7684K\u4e2a\u6570\u7ef4\u6301\u4e00\u4e2a\u5c0f\u6839\u5806 O(N*logK)
          \u6570\u7684\u8303\u56f4\u5df2\u77e5\u7684\u60c5\u51b5\u4e0b\u53ef\u4ee5\u8003\u8651\u8ba1\u6570\u6392\u5e8f,\u6876\u6392\u5e8f <\/p>\n

          \u6269\u5c55\u95ee\u9898<\/p>\n

          1\u611f\u89c9\u4e0a\u8ff0\u65b9\u6cd5\u90fd\u884c<\/p>\n

          2\u4e2a\u4eba\u89c9\u5f97\u53ef\u4ee5\u7528\u5c0f\u6839\u5806\u6765\u5148\u6c42\u51fam\u4e2a\u6700\u5927\u7684\uff0c\u7136\u540e\u4ece\u4e2d\u8f93\u51fak\u5230m\u4e2a<\/p>\n

          3\u7f51\u4e0a\u7b54\u6848\uff1a\u53ef\u4ee5\u91c7\u7528\u5c0f\u9876\u5806\u6765\u5b9e\u73b0\uff0c\u4f7f\u7528\u6620\u5c04\u4e8c\u5206\u5806\uff0c\u53ef\u4ee5\u4f7f\u66f4\u65b0\u7684\u64cd\u4f5c\u8fbe\u5230O(logn)\u3002\/\/ HASH,\u7ea2\u9ed1\u6811\u4e4b\u7c7b\u7684<\/p>\n

          \/\/ \u9700\u8981\u5c06\u5168\u90e8\u7f51\u9875\u6570\u636e\u52a0\u5165\u5230\u5806\u4e2d<\/p>\n

          4\u7f51\u4e0a\u7b54\u6848\uff1a\u7b54\uff1a\u6b63\u5982\u63d0\u793a\u4e2d\u6240\u8bf4\uff0c\u53ef\u4ee5\u8ba9\u6bcf\u53f0\u673a\u5668\u8fd4\u56de\u6700\u76f8\u5173\u7684K'\u4e2a\u6587\u6863\uff0c\u7136\u540e\u5229\u7528\u5f52\u5e76
          \u6392\u5e8f\u7684\u601d\u60f3\uff0c\u5f97\u5230\u6240\u6709\u6587\u6863\u4e2d\u6700\u76f8\u5173\u7684K\u4e2a\u3002 \u6700\u597d\u7684\u60c5\u51b5\u662f\u8fd9K\u4e2a\u6587\u6863\u5728\u6240\u6709\u673a\u5668\u4e2d\u5e73\u5747
          \u5206\u5e03\uff0c\u8fd9\u65f6\u6bcf\u53f0\u673a\u5668\u53ea\u8981K' = K \/ n \uff08n\u4e3a\u6240\u6709\u673a\u5668\u603b\u6570\uff09\uff1b\u6700\u574f\u60c5\u51b5\uff0c\u6240\u6709\u6700\u76f8\u5173\u7684K
          \u4e2a\u6587\u6863\u53ea\u51fa\u73b0\u5728\u5176\u4e2d\u7684\u67d0\u4e00\u53f0\u673a\u5668\u4e0a\uff0c\u8fd9\u65f6K'\u9700\u8fd1\u4f3c\u7b49\u4e8eK\u4e86\u3002\u6211\u89c9\u5f97\u6bd4\u8f83\u597d\u7684\u505a\u6cd5\u53ef\u4ee5
          \u5728\u6bcf\u53f0\u673a\u5668\u4e0a\u7ef4\u62a4\u4e00\u4e2a\u5806\uff0c\u7136\u540e\u5bf9\u5806\u9876\u5143\u7d20\u5b9e\u884c\u5f52\u5e76\u6392\u5e8f\u3002<\/p>\n

          5\u7f51\u4e0a\u7b54\u6848\uff1a\u7b54\uff1a\u80af\u5b9a\u662f\u6709\u5e2e\u52a9\u7684\u3002 qi\u6700\u76f8\u5173\u7684K\u4e2a\u6587\u6863\u53ef\u80fd\u5c31\u662fqj\u7684\u6700\u76f8\u5173\u7684K\u4e2a\u6587\u6863\uff0c\u53ef\u4ee5\u5148\u5047
          \u8bbe\u8fd9K\u4e2a\u5c31\u662f\uff0c\u7136\u540e\u6839\u636e\u95ee\u9898\u56db\u7684\u89e3\u6cd5\u83b7\u5f97K'\uff0c\u5206\u522b\u548c\u8fd9K\u4e2a\u6bd4\u8f83\uff0c\u53ef\u4ee5\u7528\u5806\u8fdb\u884c\u6bd4\u8f83\uff0c\u4ece
          \u800c\u83b7\u5f97qj\u6700\u76f8\u5173\u7684K\u4e2a\u6587\u6863\u3002\u7531\u4e8e\u6700\u5f00\u59cb\u7684K\u4e2a\u6587\u6863\u6781\u6709\u53ef\u80fd\u662f\u6700\u7ec8\u7684K\u4e2a\u6587\u6863\uff0c\u6240\u4ee5K'\u548cK
          \u6bd4\u8f83\u7684\u6b21\u6570\u53ef\u80fd\u5e76\u4e0d\u591a\u3002<\/p>\n

          <\/p>\n

          2.6 \u7cbe\u786e\u8868\u8fbe\u6d6e\u70b9\u6570<\/p>\n

          \u5206\u60c5\u51b5\u8ba8\u8bba\uff0c\u63a8\u5bfc\u901a\u7528\u516c\u5f0f <\/p>\n

          2.7 \u6700\u5927\u516c\u7ea6\u6570<\/p>\n

          \u8f97\u8f6c\u76f8\u9664\u6cd5
          \u8f97\u8f6c\u76f8\u51cf\u6cd5
          \u5947\u5076\u5224\u65ad\u7684\u8f97\u8f6c\u76f8\u51cf\u6cd5 <\/p>\n

          2.8 \u627e\u7b26\u5408\u6761\u4ef6\u7684\u6574\u6570<\/p>\n

          <\/p>\n

          \u53c2\u8003: http:\/\/blog.csdn.net\/jcwKyl\/article\/details\/<\/p>\n

          \u6269\u5c55\u95ee\u9898\u4e00<\/p>\n

          \n

          \u9898\u76ee\uff1a\u4efb\u610f\u7ed9\u5b9a\u4e00\u4e2a\u6b63\u6574\u6570N\uff0c\u6c42\u4e00\u4e2a\u6700\u5c0f\u7684\u6b63\u6574\u6570M(M>1)\uff0c\u4f7f\u5f97N*M\u7684\u5341\u8fdb\u5236\u8868\u793a\u5f62\u5f0f\u91cc\u53ea\u542b\u67091\u548c0.<\/p>\n

          \u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u9996\u5148\u8003\u8651\u5bf9\u4e8e\u4efb\u610f\u7684N\uff0c\u662f\u5426\u8fd9\u6837\u7684M\u4e00\u5b9a\u5b58\u5728\u3002\u53ef\u4ee5\u8bc1\u660e\uff0cM\u662f\u4e00\u5b9a\u5b58\u5728\u7684\uff0c\u800c\u4e14\u4e0d\u552f\u4e00\u3002
          \u7b80\u5355\u8bc1\u660e\uff1a\u56e0\u4e3a<\/p>\n

           \"\u6269\u5927\u7f16\u7a0b_\u7f16\u7a0b\u5728\u751f\u6d3b\u4e2d\u7684\u5e94\u7528\u7684\u4f8b\u5b50<\/p>\n

          \u8fd9\u662f\u4e00\u4e2a\u65e0\u7a77\u6570\u5217\uff0c\u4f46\u662f\u6570\u5217\u4e2d\u7684\u6bcf\u4e00\u9879\u53d6\u503c\u8303\u56f4\u90fd\u5728[0, N-1]\u4e4b\u95f4\u3002\u6240\u4ee5\u8fd9\u4e2a\u65e0\u7a77\u6570\u5217\u4e2d\u95f4\u5fc5\u5b9a\u5b58\u5728\u5faa\u73af\u8282\u3002\u5373\u5047\u8bbe\u6709s,t\u5747\u662f\u6b63\u6574\u6570\uff0c\u4e14s<t\uff0c\u6709 \u3002\u4e8e\u662f\u5faa\u73af\u8282\u957f\u5ea6\u4e3at-s\u3002\u4e8e\u662f10^s = 10^t\u3002\u56e0\u6b64\u6709\uff1a
          \"\u6269\u5927\u7f16\u7a0b_\u7f16\u7a0b\u5728\u751f\u6d3b\u4e2d\u7684\u5e94\u7528\u7684\u4f8b\u5b50\uff0c\u6240\u4ee5
          \"\u6269\u5927\u7f16\u7a0b_\u7f16\u7a0b\u5728\u751f\u6d3b\u4e2d\u7684\u5e94\u7528\u7684\u4f8b\u5b50<\/p>\n

          \u4f8b\u5982\uff0c\u53d6N\uff1d3\uff0c\u56e0\u4e3a10\u7684\u4efb\u4f55\u975e\u8d1f\u6b21\u65b9\u6a213\u90fd\u4e3a1\uff0c\u6240\u4ee5\u5faa\u73af\u8282\u5468\u671f\u4e3a1.\u6709\uff1a<\/p>\n

          \"\u6269\u5927\u7f16\u7a0b_\u7f16\u7a0b\u5728\u751f\u6d3b\u4e2d\u7684\u5e94\u7528\u7684\u4f8b\u5b50<\/p>\n

          \u7ed9\u5b9aN\uff0c\u6c42M\u7684\u65b9\u6cd5\uff1a
          \u65b9\u6cd5\u4e00\uff1a\u7ed9\u5b9aN\uff0c\u4ee4M\u4ece2\u5f00\u59cb\uff0c\u679a\u4e3eM\u7684\u503c\u76f4\u5230\u9047\u5230\u4e00\u4e2aM\u4f7f\u5f97N*M\u7684\u5341\u8fdb\u5236\u8868\u793a\u4e2d\u53ea\u67091\u548c0.
          \u65b9\u6cd5\u4e8c\uff1a\u6c42\u51fa10\u7684\u6b21\u65b9\u5e8f\u5217\u6a21N\u7684\u4f59\u6570\u5e8f\u5217\u5e76\u627e\u51fa\u5faa\u73af\u8282\u3002\u7136\u540e\u641c\u7d22\u8fd9\u4e2a\u4f59\u6570\u5e8f\u5217\uff0c\u641c\u7d22\u7684\u76ee\u7684\u5c31\u662f\u8981\u5728\u8fd9\u4e2a\u4f59\u6570\u5e8f\u5217\u4e2d\u627e\u5230\u4e00\u4e9b\u6570\u51fa\u6765\u8ba9\u5b83\u4eec\u7684\u548c\u662fN\u7684\u500d\u6570\u3002\u4f8b\u5982N=13\uff0c\u8fd9\u4e2a\u5e8f\u5217\u5c31\u662f1,10,9,12,3,4\u7136\u540e\u4e0d\u65ad\u5faa\u73af\u3002\u5f88\u660e\u663e\u67091+12=13\uff0c\u800c1\u662f10\u76840\u6b21\u65b9\uff0c12\u662f10\u76843\u6b21\u65b9\uff0c\u6240\u4ee5\u8fd9\u4e2a\u6570\u5c31\u662f1000+1=1001\uff0cM\u5c31\u662f1001\/13=77\u3002
          \u65b9\u6cd5\u4e09\uff1a\u56e0\u4e3aN*M\u7684\u53d6\u503c\u5c31\u662f1,10,11,100,101,110,111,......\u6240\u4ee5\u76f4\u63a5\u5728\u8fd9\u4e2a\u7a7a\u95f4\u641c\u7d22\uff0c\u8fd9\u662f\u5bf9\u65b9\u6cd5\u4e00\u7684\u6539\u8fdb\u3002\u641c\u7d22\u8fd9\u4e2a\u5e8f\u5217\u76f4\u5230\u627e\u5230\u4e00\u4e2a\u80fd\u88abN\u6574\u9664\u7684\u6570\uff0c\u5b83\u5c31\u662fN*M\uff0c\u7136\u540e\u53ef\u8ba1\u7b97\u51faM\u3002\u4f8b\u5982N=3\u65f6\uff0c\u641c\u7d22\u6811\u5982\u4e0b\uff1a
          \"\u6269\u5927\u7f16\u7a0b_\u7f16\u7a0b\u5728\u751f\u6d3b\u4e2d\u7684\u5e94\u7528\u7684\u4f8b\u5b50
          \u4e0a\u56fe\u4e2d\u62ec\u53f7\u5185\u8868\u793a\u6a213\u7684\u4f59\u6570\u3002\u62ec\u53f7\u5916\u8868\u793a\u88ab\u641c\u7d22\u7684\u6570\u3002\u5de6\u5b50\u6811\u8868\u793a0\uff0c\u53f3\u5b50\u6811\u8868\u793a1.\u4e0a\u56fe\u4e2d\u641c\u7d22\u5230\u7b2c\u4e8c\u5c42\uff08\u6839\u662f\u7b2c0\u5c42\uff09\u65f6\u9047\u5230111\uff0c\u5b83\u6a213\u4f59\u6570\u4e3a0.\u6240\u4ee5N*M=111, M=111\/3=37\u3002
          \u65b9\u6cd5\u56db\uff1a\u5bf9\u65b9\u6cd5\u4e09\u7684\u6539\u8fdb\u3002\u5c06\u65b9\u6cd5\u4e09\u7684\u641c\u7d22\u7a7a\u95f4\u6309\u6a21N\u4f59\u6570\u5206\u7c7b\uff0c\u4f7f\u5f97\u641c\u7d22\u65f6\u95f4\u548c\u7a7a\u95f4\u90fd\u7531\u539f\u6765\u7684\u6307\u6570\u7ea7\u964d\u5230\u4e86O(N)\u3002\u6539\u8fdb\u7684\u539f\u7406\uff1a\u5047\u8bbe\u5f53\u524d\u6b63\u5728\u641c\u7d22\u75310\uff0c1\u7ec4\u6210\u7684K\u4f4d\u5341\u8fdb\u5236\u6570\uff0c\u8fd9\u6837\u7684K\u4f4d\u5341\u8fdb\u5236\u6570\u5171\u67092^k\u4e2a\u3002\u5047\u8bbe\u5176\u4e2d\u6709\u4e24\u4e2a\u6570X\u3001Y\uff0c\u5b83\u4eec\u6a21N\u540c\u4f59\uff0c\u90a3\u4e48\u5728\u641c\u7d22\u75310\u30011\u7ec4\u6210\u7684K+1\u4f4d\u5341\u8fdb\u5236\u6570\u65f6\uff0cX\u548cY\u4f1a\u88ab\u6269\u5c55\u51fa\u56db\u4e2a\u6570\uff1a10X, 10X+1, 10Y, 10Y+1\u3002\u56e0\u4e3aX\u548cY\u540c\u4f59\uff08\u540c\u4f59\u5b8c\u5168\u53ef\u4ee5\u770b\u4f5c\u76f8\u7b49\uff09\uff0c\u6240\u4ee510X\u4e0e10Y\u540c\u4f59\uff0c10X+1\u4e0e10Y+1\u540c\u4f59\u3002\u4e5f\u5c31\u662f\u8bf4\u7531Y\u6269\u5c55\u51fa\u6765\u7684\u5b50\u6811\u548c\u7531X\u6269\u5c55\u4ea7\u751f\u51fa\u6765\u7684\u5b50\u6811\u4ea7\u751f\u5b8c\u5168\u76f8\u540c\u7684\u4f59\u6570\uff0c\u5982\u679cX\u6bd4Y\u5c0f\uff0c\u90a3\u4e48Y\u80af\u5b9a\u4e0d\u662f\u6ee1\u8db3\u8981\u6c42\u7684\u6700\u5c0f\u7684\u6570\uff0c\u6240\u4ee5Y\u8fd9\u68f5\u5b50\u6811\u53ef\u4ee5\u88ab\u526a\u6389\u3002\u8fd9\u6837\uff0c2^K\u4e2a\u6570\u6309\u7167\u6a21N\u4f59\u6570\u5206\u7c7b\uff0c\u6bcf\u7c7b\u4e2d\u53ea\u4fdd\u7559\u6700\u5c0f\u7684\u90a3\u4e2a\u6570\u4ee5\u4f9b\u6269\u5c55\u3002\u539f\u6765\u5728\u8fd9\u4e00\u5c42\u9700\u8981\u641c\u7d222^K\u4e2a\u6570\uff0c\u73b0\u5728\u53ea\u9700\u8981\u641c\u7d22O(N)\u4e2a\u6570\u3002\u4f8b\u5982\uff0c\u5f53N=9\u65f6\uff0c\u7b2c0\u5c42\u662f1(1)\uff0c
          \"\u6269\u5927\u7f16\u7a0b_\u7f16\u7a0b\u5728\u751f\u6d3b\u4e2d\u7684\u5e94\u7528\u7684\u4f8b\u5b50
          \u5982\u4e0a\u56fe\u6240\u793a\uff0c\u7b2c2\u5c42\u7684110\uff0c\u7b2c\u4e09\u5c42\u76841010\u30011110\u90fd\u56e0\u4e3a\u540c\u4e00\u5c42\u6709\u548c\u5b83\u540c\u4f59\u4e14\u66f4\u5c0f\u7684\u6570\u800c\u88ab\u526a\u6389\u3002\u5982\u679c\u6309\u7167\u65b9\u6cd5\u4e09\u641c\u7d22\uff0c\u7b2c\u4e09\u5c42\u672c\u6765\u5e94\u8be5\u67098\u4e2a\u7ed3\u70b9\uff0c\u4f46\u73b0\u5728\u53ea\u67094\u4e2a\u7ed3\u70b9\u3002 <\/p>\n


          <\/p>\n

          \u53e6\u7f16\u7a0b\u4e4b\u7f8e\u601d\u8def\u4e0e\u4e0a\u9762\u4e00\u81f4,\u90fd\u662f\u540c\u4f59\u526a\u679d,\u6784\u90201,0\u7684\u6570\u904d\u5386,\u5c06\u8be5\u6570z\u5206\u89e3\u4e3az=a+b,\u7136\u540e\u5229\u7528\u4f59\u6570\u4fe1\u606f\u6570\u7ec4\u4e2da%N+b%N\u7684\u503c\u518d%N,\u8ba1\u7b97z%N\u7684\u503c;<\/p>\n

          \u601d\u8def\u7528\u5230\u7684\u6570\u5b66\u516c\u5f0f\u662f (a+b)%c=(a%c+b%c)%c <\/p>\n

          \u4f8b\u5982:<\/p>\n

          \u8ba1\u7b97110\u65f6,100\u6a21N\u7684\u503c\u5df2\u7ecf\u5f97\u5230\u4e3a1,110%N=(100%N(1)+10%N(1))%N=2<\/p>\n

          <\/p>\n

          \u6269\u5c55\u95ee\u9898\u4e8c<\/p>\n

          \u627e\u51fa\u6ee1\u8db3\u9898\u76ee\u8981\u6c42\u7684N\u548cM,\u4f7f\u5f97N*M<2^16,\u4e14N+M\u6700\u5927<\/p>\n

          \u5982\u679cN\u5df2\u77e5\u5219\u6c42M,\u7136\u540e\u6c42MAX(N+M),  2^16=65536,\u53ea\u67095\u4f4d<\/p>\n

          \u5982\u679cN\u672a\u77e5,\u6839\u636e\u6570\u5b66\u516c\u5f0f\u53ef\u4ee5\u6709N*M\u4e00\u5b9a,N+M\u6700\u5c0f\u5219,N==M,N+M\u6700\u5927\u4e00\u5b9a\u662fN\u5f88\u5c0f\u6216M\u5f88\u5c0f\u7684\u60c5\u51b5(\u5177\u4f53\u63a8\u5bfc\u8fc7\u7a0b\u4e0d\u597d\u7f16\u8f91,\u5148\u6254\u4e00\u8fb9)<\/p>\n

          \u7ed9\u5b9aN=1,\u7136\u540eM=N*M,\u5373\u4e3a\u6240\u6c42\/\/ by zj \u770b\u4e86\u4e0b\u9898\u76ee,N\u4e3a\u6b63\u6574\u6570,M>1,\u6c42\u4e00\u4e2a\u6700\u5c0f\u7684\u6b63\u6574\u6570,\u8fd9\u4e2a\u9898\u610f\u771f\u4e0d\u597d\u7406\u89e3\u4e86....<\/p>\n

          <\/p>\n

          2.9\u6590\u6ce2\u90a3\u5951(Fibonacci)\u6570\u5217<\/p>\n

          \u601d\u8def<\/p>\n

          1\u9012\u5f52,\u95ee\u9898\u6709\u5f88\u591a\u91cd\u590d<\/p>\n

          2\u5e26\u8bb0\u5f55\u7684\u5411\u540e\u8ba1\u7b97<\/p>\n

          3\u7279\u5f81\u65b9\u7a0b\u6c42\u89e3,\u4f46\u4f1a\u4ea7\u751f\u65e0\u7406\u6570\u95ee\u9898<\/p>\n

          4\u77e9\u9635\u8ba1\u7b97,\u5176\u4e2d\u53ef\u4ee5\u7528\u5230\u4e8c\u5206\u6c42\u5e42\u6cd5,\u65f6\u95f4\u590d\u6742\u5ea6\u8fdb\u5316\u4e3aO(LOGN)<\/p>\n

          \u6269\u5c55\u95ee\u9898<\/p>\n

          \u6784\u9020\u65b9\u5e42\u578b\u77e9\u9635,\u5f53N\u5f88\u5927\u65f6,\u53ef\u4ee5\u8ba1\u7b97\u51faMOD\u7684\u7ed3\u679c,\u6bcf\u4e00\u6b21\u8ba1\u7b97\u90fd\u6c42MOD<\/p>\n

          <\/p>\n

          2.10 \u5bfb\u627e\u6570\u7ec4\u4e2d\u7684\u6700\u5927\u503c\u548c\u6700\u5c0f\u503c<\/p>\n

          \u4ece2N\u51cf\u5c11\u52301.5N,\u4e3b\u8981\u662f\u4e24\u4e24\u4e3a\u4e00\u5355\u4f4d\u8fdb\u884cMAX \u548cMIN\u7684\u6bd4\u8f83<\/p>\n

          \u6269\u5c55\u95ee\u9898<\/p>\n

          \u6c42\u6b21\u5927\u503c<\/p>\n

          \u601d\u8def1\u662fMAX SECOND,<\/p>\n

          \u5982\u679cX\u6bd4MAX\u5927,\u5219SECOND=MAX,MAX=X;<\/p>\n

          \u5982\u679cX\u6bd4MAX\u5c0f,\u5219X\u4e0eSECOND\u6bd4\u8f83\u518d\u4ea4\u6362<\/p>\n

          \u6bd4\u8f83\u6b21\u6570\u5728N\u52302N\u4e4b\u95f4<\/p>\n

          \u601d\u8def2\u4eff\u7167\u6c42\u6700\u5927\u503c\u6700\u5c0f\u503c<\/p>\n

          MAX SECOND<\/p>\n

          \u6bcf\u4e24\u4e2a\u4e3a\u4e00\u7ec4,A[I]\u5c0f\u4e8eA[I+1]<\/p>\n

          \u5982\u679cMAX<A[I+1],\u5219SECOND=MAX,MAX=X;<\/p>\n

          \u5982\u679cMAX>A[I+1],\u5219\u518d\u6bd4\u8f83A[I+1]\u4e0eSECOND;\/\/ \u6ce8\u610f\u8fd9\u70b9 \u8d70\u5230\u8fd9\u91cc,\u4e0b\u53e5\u8981\u8df3\u8fc7,\u56e0\u4e3aA[I+1]\u6bd4A[I]\u5927,SECOND\u4e0d\u7528\u518d\u548cA[I]\u6bd4\u8f83<\/p>\n

          \u5982\u679cA[I]>SECOND,\u5219\u518d\u4ea4\u6362;<\/p>\n

          \/\/ \u4f8b\u5b50\u5982   5 10 8 9 11 15 <\/p>\n

          \u6bd4\u8f83\u6b21\u6570\u4e3a0.5N+0.5N+0.5N=1.5N<\/p>\n

          <\/p>\n

          2.11\u5bfb\u627e\u6700\u8fd1\u70b9\u5bf9<\/p>\n

          \u5206\u6cbb\u601d\u60f3\u7684\u5229\u7528,O(N*LOGN)<\/p>\n

          \u6269\u5c55\u95ee\u98981<\/p>\n

          \u7c7b\u4f3c\u6876\u6392\u5e8f,\u5173\u952e\u662f\u76f8\u90bb\u4e24\u4e2a\u6570\u7684\u610f\u4e49<\/p>\n

          \u7b80\u5355\u65b9\u6cd5\u662f\u6392\u5e8f,\u7136\u540e\u8ba1\u7b97\u76f8\u90bb\u6570\u7684\u5dee\u503c,\u7136\u540e\u518d\u6c42MAX,O(N*LOGN)<\/p>\n

          \u4e66\u4e2d\u7684\u65b9\u6cd5\u662f\u6876\u6392\u5e8f\u6216\u8005\u8bf4\u662f\u62bd\u5c49\u539f\u7406\u7684\u4f7f\u7528,\u7136\u540e\u5728\u4e24\u4e2a\u6876\u95f4\u7684\u6700\u5927\u503c \u4e0e\u6700\u5c0f\u503c\u5f97\u5dee\u6c42MAX,\u7a7a\u95f4O(N)\u65f6\u95f4O(N)<\/p>\n

          \u6269\u5c55\u95ee\u98982<\/p>\n

          \u53c2\u8003:<\/p>\n

          http:\/\/blog.csdn.net\/hackbuteer1\/article\/details\/ <\/p>\n

          \u4e24\u4e2a\u65b9\u6cd5<\/p>\n

          1\u51e0\u4f55\u601d\u60f3,\u6c42\u51f8\u5305\u76f4\u5f84O(N*LOGN)<\/p>\n

          2\u51f8\u5305\u8fb9\u4e0e\u5176\u6700\u8fdc\u70b9\u8ddd\u79bb\u7684\u626b\u63cfO(N)<\/p>\n

          <\/p>\n

          2.12 \u5feb\u901f\u5bfb\u627e\u6ee1\u8db3\u6761\u4ef6\u7684\u4e24\u4e2a\u6570<\/p>\n

          \u6269\u5c55\u95ee\u9898\/\/ by zjerry \u5148\u653e\u4e00\u653e,\u627e\u5230\u89e3\u51b33\u7684\u65b9\u6cd5\u5c31\u89e3\u51b3\u4e861,2,\u5173\u952e\u7406\u89e3NP,NPC\u95ee\u9898<\/p>\n

          1<\/p>\n

          2<\/p>\n

          3<\/p>\n

          <\/p>\n

          2.13 \u5b50\u6570\u7ec4\u7684\u6700\u5927\u4e58\u79ef<\/p>\n

          \u601d\u8def<\/p>\n

          \u4e0d\u8bb8\u7528\u4e58\u9664\u6cd5,\u8ba1\u7b97N-1\u4e2a\u4e58\u79ef\u6700\u5927\u7684\u4e00\u7ec4<\/p>\n

          <\/p>\n

          \u65b9\u6cd51 <\/span>\u7a7a\u95f4\u6362\u65f6\u95f4,O(N),\u5229\u7528\u4e24\u4e2a\u6570\u7ec4\u6765\u8fdb\u884c\"-1\"\u7684\u64cd\u4f5c <\/p>\n

          \u65b9\u6cd52     \u5224\u65adN\u4e2a\u6570\u7684\u4e58\u79efP\u7684\u6b63\u8d1f\u6027,\u6765\u63a8\u7406\u51fa\u5e94\u8be5\"-1\"\u51cf\u53bb\u4ec0\u4e48\u6837\u7684\u6570,O(N)<\/p>\n

          <\/p>\n

          2.14 \u6c42\u6570\u7ec4\u7684\u5b50\u6570\u7ec4\u4e4b\u548c\u7684\u6700\u5927\u503c<\/p>\n

          \u8fd9\u91cc\u7684\u5b50\u6570\u7ec4\u6307\u8fde\u7eed\u5b50\u6570\u7ec4<\/p>\n

          \u601d\u8defDP,\u65b9\u6cd5O(N),\u5224\u65ad\u5f53\u524d\u503c+\u4e4b\u524d\u7684\u548c,\u662f\u5426\u5c0f\u4e8e0,\u5c0f\u4e8e0,\u5219\u5c06\u548c\u5f52\u4e3a0,\u91cd\u65b0\u5f00\u59cb\u5bfb\u627e\u5b50\u6570\u7ec4\u7684\u6700\u5927\u503c<\/p>\n

          \u6269\u5c551<\/p>\n

          \u5206\u4e3a\u4e24\u4e2a\u5b50\u95ee\u9898<\/p>\n

          \u6269\u5c552<\/p>\n

          \u8fd4\u56de\u5b50\u6570\u7ec4\u4f4d\u7f6e,\u6ce8\u610f\u7b97\u6cd5\u4e2d\u4f55\u65f6\u66f4\u6539\u4e86\u548c\u503c,\u5219\u4e0a\u4e00\u4e2a\u6570\u5c31\u4e3a\u4e0a\u4e00\u8f6e\u7684END,\u5f53\u524d\u6570\u4e3a\u65b0\u4e00\u8f6e\u7684BEGIN;\u5728\u6700\u5927\u503c\u6bd4\u8f83\u65f6,\u4fdd\u5b58\u76f8\u5e94\u7684BEGIN\u548cEND<\/p>\n

          <\/p>\n

          2.15 \u5b50\u6570\u7ec4\u4e4b\u548c\u7684\u6700\u5927\u503c(\u4e8c\u7ef4)<\/p>\n

          \u6269\u5c55\/\/ by zjerry \u57fa\u672c\u601d\u8def\u5c31\u662f\u5411\u4f4e\u7ef4\u8f6c\u5316,\u6709\u4e00\u70b9\u6ce8\u610f,\u6e38\u6cf3\u5708\u90a3\u79cd,\u5982\u4f55\u8fdb\u884c\u4e0a\u4e0b,\u5de6\u53f3\u90fd\u50cf\u4e00\u7ef4\u4e00\u6837\u7684\u5206\u4e24\u79cd\u60c5\u51b5\u8ba8\u8bba(\u6709\u53ef\u80fd\u6700\u5927\u503c\u5728\u4e0a\u4e0b\u5de6\u53f3\u4ea4\u7ed3\u7684\u4f4d\u7f6e)<\/p>\n

          1<\/p>\n

          2<\/p>\n

          3<\/p>\n

          4<\/p>\n

          <\/p>\n

          2.16 \u6c42\u6570\u7ec4\u4e2d\u6700\u957f\u9012\u589e\u5b50\u5e8f\u5217<\/p>\n

          \u65b9\u6cd5\u4e00:\u7528\u4e00\u4e2a\u6570\u7ec4\u4fdd\u5b58\u5230\u5f53\u524d\u4f4d\u65f6\u7684\u6700\u5927\u5b50\u5e8f\u5217\u4e2a\u6570,DP\u601d\u60f3\u6c42\u89e3,O(N^2)<\/p>\n

          \u65b9\u6cd5\u4e8c:\u7528\u4e00\u4e2aMAX\u6570\u7ec4\u4fdd\u5b58\u957f\u5ea6\u4e3aI\u7684\u9012\u589e\u5b50\u5e8f\u5217\u6700\u5927\u5143\u7d20\u7684\u6700\u5c0f\u503c,\u4f8b\u59821 -1 2 -3 4 -5 6 -7 \u4e2d\u957f\u5ea6\u4e3a2\u7684MAX[2]=2,<\/p>\n

          \u904d\u5386\u8fd9\u4e2aMAX\u503c\u6765\u8fdb\u884c\u5224\u65ad\u5b50\u5e8f\u5217\u4e2a\u6570\u662f\u5426\u8981\u52a01,<\/p>\n

          \u5229\u7528\u8d2a\u5fc3\u601d\u60f3,\u6bcf\u904d\u5386\u7684\u4e00\u4e2a\u6570\u5982\u679c\u5927\u4e8e\u5219\u8ffd\u52a0,\u540c\u65f6\u66f4\u65b0\u8fd9\u4e2a\u65b0\u5b50\u5e8f\u5217\u7684MAX\u503c,<\/p>\n

          \u590d\u6742\u5ea6\u4ecd\u4e3aO(N^2)<\/p>\n

          \u65b9\u6cd5\u4e09:\u5c06\u904d\u5386MAX\u6570\u7ec4\u6539\u8fdb\u4e3a\u4e8c\u5206\u67e5\u627e,\u4ece\u800c\u4f7f\u5185\u5c42\u5faa\u73af\u53d8\u4e3aLOGN,\u603b\u7684\u590d\u6742\u5ea6\u964d\u4e3aO(N*LOGN)<\/p>\n

          <\/p>\n

          2.17 \u6570\u7ec4\u5faa\u73af\u79fb\u4f4d<\/p>\n

          \u4e09\u6b21REVERSE<\/p>\n

          \u65f6\u95f4\u590d\u6742\u5ea6O(N)<\/p>\n

          <\/p>\n

          2.18 \u6570\u7ec4\u5206\u5272<\/p>\n

          \/\/ by zjerry<\/p>\n

          \u6ca1\u5b8c\u5168\u7406\u89e3,\u8981\u7ed3\u5408DP,\u80cc\u5305\u7b49\u5185\u5bb9\u770b<\/p>\n

          \u6269\u5c55\u95ee\u9898<\/p>\n

          \u9488\u5bf9\u8d1f\u6570,\u53ef\u4ee5\u5148\u5c06\u6240\u6709\u6570+\u6700\u5c0f\u8d1f\u6570\u7684\u7edd\u5bf9\u503c,\u4f7f\u6240\u6709\u6570\u53d8\u4e3a\u6b63\u6570,\u7136\u540e\u518d\u89e3(\u56e0\u4e3a\u5206\u5272\u53ea\u662f\u4e3a\u4e86\u5206\u6210\u5dee\u503c\u5c0f\u7684\u4e24\u7ec4\u6570)<\/p>\n

          <\/p>\n

          2.19 \u533a\u95f4\u91cd\u5408\u5224\u65ad<\/p>\n

          \u89e3\u6cd5\u4e00\u662f\u5c06\u6240\u7ed9\u7684\u533a\u95f4\u5411\u6e90\u533a\u95f4\u4e0a\u6295\u5f71,\u6807\u8bb0\u672a\u88ab\u8986\u76d6\u7684\u533a\u95f4,\u65f6\u95f4\u590d\u6742\u5ea6\u662fO(N^2)(\u5916\u5c42\u5faa\u73af\u662fN\u4e2a\u6240\u7ed9\u533a\u95f4O(N),\u5185\u5c42\u5faa\u73af\u662f\u6bcf\u6b21\u66f4\u65b0\u672a\u88ab\u8986\u76d6\u7684\u533a\u95f4\u6570\u7ec4O(N))<\/p>\n

          \u89e3\u6cd5\u4e8c\u662f\u5bb9\u6613\u60f3\u5230\u7684\u529e\u6cd5,<\/p>\n

          \u5148\u6309\u533a\u95f4\u5de6\u8fb9\u503c\u6392\u5e8fO(NLOGN)<\/p>\n

          \u5408\u5e76\u533a\u95f4O(N)<\/p>\n

          \u4e8c\u5206\u67e5\u627e\u6e90\u533a\u95f4\u5728\u5408\u5e76\u540e\u7684\u8303\u56f4O(LOGN)<\/p>\n

          \u5355\u6b21\u67e5\u627e\u5c31\u662f\u7b2c\u4e09\u90e8O(LOGN)<\/p>\n

          \u6269\u5c55\u95ee\u9898<\/p>\n

          \u53c2\u8003:http:\/\/blog.csdn.net\/linyunzju\/article\/details\/<\/p>\n

          \/\/ by zjerry<\/p>\n

          <\/p>\n

          2.20 \u7a0b\u5e8f\u7406\u89e3\u548c\u65f6\u95f4\u5206\u6790<\/p>\n

          \u95ee\u9898<\/p>\n

          \n

          \u7406\u89e3\u8fd9\u4e2a\u7a0b\u5e8f\u5c31\u662f\u4ece\u8f93\u51fa\u7684\u5730\u65b9\u5f80\u524d\u8ffd\u6eaf<\/strong>\u5c31\u53ef\u4ee5\u3002\u8fd9\u4e2a\u7a0b\u5e8f\u8f93\u51fa\u7684\u6761\u4ef6\u662fhit==2&&(hit1+1==hit2)\uff0c\u518d\u5f80\u524d\u8ffd\u6eaf\u770bhit,hit1,hit2\u4e09\u4e2a\u53d8\u91cf\u5206\u522b\u4ee3\u8868\u4ec0\u4e48\uff0chit\u8868\u793a\u6ee1\u8db3i%r[j]!=0\u7684\u6761\u4ef6\u7684\u6b21\u6570\uff0chit==2\u8868\u793a\u8fd9\u4e2a\u6761\u4ef6\u53ea\u80fd\u88ab\u6ee1\u8db3\u4e24\u6b21\uff0c\u4e5f\u5c31\u662f\u8bf4\u5bf9\u4e8e\u4e00\u4e2ai\uff0c\u5728rg\u6570\u7ec4\u768430\u4e2a\u6570\u4e2d\uff0c\u8fd9\u4e2ai\u80fd\u88ab\u5176\u5b8328\u4e2a\u6570\u6574\u9664\uff0c\u800c\u4e0d\u80fd\u88ab\u5176\u4e2d\u4e24\u4e2a\u6570\u6574\u9664\u3002\u800chit1\u8868\u793a\u7b2c\u4e00\u4e2a\u4e0d\u80fd\u6574\u9664i\u7684\u6570\u7684\u4e0b\u6807\uff0chit2\u8868\u793a\u7b2c\u4e8c\u4e2a\u4e0d\u80fd\u6574\u9664i\u7684\u4e0b\u6807\uff0c\u8fd9\u4e24\u4e2a\u4e0b\u6807\u88ab\u8981\u6c42\u76f8\u5dee\u53ea\u67091\u3002\u4e8e\u662f\uff0c\u7a0b\u5e8f\u6240\u8981\u5bfb\u627e\u7684\u662f\u8fd9\u6837\u7684\u6570\uff1a\u8fd9\u4e2a\u6570i\u4e0d\u80fd\u88ab2-31\u8fd930\u4e2a\u6570\u4e2d\u7684\u4e24\u4e2a\u76f8\u90bb\u7684\u6570\u6574\u9664\uff0c\u4f46\u80fd\u88ab\u5176\u5b8328\u4e2a\u6570\u6574\u9664\u3002<\/strong>\u6240\u4ee5\uff0c\u8fd9\u4e2ai\u80af\u5b9a\u662f\u5176\u5b8328\u4e2a\u6570\u7684\u6700\u5c0f\u516c\u500d\u6570\u7684\u6574\u6570\u500d\u3002\u7136\u800ci\u4e0d\u80fd\u88ab\u4e24\u4e2a\u76f8\u90bb\u7684\u6570\u6574\u9664\uff0c\u6240\u4ee5\u5fc5\u7136\u662f\u5206\u89e3\u8d28\u56e0\u5b50\u540e\u8981\u4e48i\u7684\u8d28\u56e0\u5b50\u4e2d\u4e0d\u5305\u62ec\u8fd9\u4e24\u4e2a\u6570\u7684\u8d28\u56e0\u5b50\uff0c\u8981\u4e48\u662fi\u7684\u8d28\u56e0\u5b50\u7684\u6b21\u6570\u5c0f\u4e8e\u8fd9\u4e24\u4e2a\u6570\u4e2d\u76f8\u540c\u8d28\u56e0\u5b50\u7684\u6b21\u6570\u3002<\/strong><\/p>\n

          \u90a3\u4e48\uff0c\u53ea\u9700\u8981\u7ed92-31\u8fd930\u4e2a\u6570\u5206\u89e3\u8d28\u56e0\u6570\uff0c\u627e\u4e00\u4e0b\u662f\u5426\u6709\u8fd9\u6837\u7684\u76f8\u90bb\u7684\u4e24\u4e2a\u6570\uff0c\u8981\u4e48\u5b83\u4eec\u7684\u8d28\u56e0\u5b50\u4e2d\u6709\u5176\u5b83\u6570\u6ca1\u6709\u7684\u8d28\u56e0\u5b50\uff0c\u8981\u4e48\u5bf9\u4e8e\u76f8\u540c\u7684\u4e00\u4e2a\u8d28\u56e0\u5b50\uff0c\u8fd9\u4e24\u4e2a\u6570\u5305\u542b\u8fd9\u4e2a\u8d28\u56e0\u5b50\u7684\u6b21\u6570\u9ad8\u4e8e\u5176\u5b83\u6240\u6709\u6b21\u6570\u3002<\/strong><\/p>\n

          16\u300117\u300119\u300123\u300125\u300127\u300129\u300131\u8fd9\u51e0\u4e2a\u6570\u5305\u542b\u6b21\u6570\u6700\u9ad8\u7684\u8d28\u56e0\u5b50\u3002\u800c\u76f8\u90bb\u7684\u5219\u53ea\u670916\uff0c17<\/strong>\u3002\u6240\u4ee5\uff0c\u8fd9\u6bb5\u7a0b\u5e8f\u6240\u8981\u6c42\u7684\u6570i\u5c31\u662f\uff0c\u5b83\u4e0d\u80fd\u88ab16\u300117\u6574\u9664\uff0c\u4f46\u80fd\u88ab30\u4e2a\u6570\u4e2d\u7684\u5176\u5b8328\u4e2a\u6570\u6574\u9664\uff0c\u6700\u5c0f\u7684i\u5c31\u662f\u5176\u5b8328\u4e2a\u6570\u7684\u6700\u5c0f\u516c\u500d\u6570\uff0c\u4ece\u4e0a\u8868\u4e2d\u77e5\u9053\uff0c\u8fd9\u4e2a\u6700\u5c0f\u7684i\u662f\uff1a2<\/span>3<\/sup>*3<\/span>3<\/sup>*5<\/span>2<\/sup>*7*11*13*19*23*29*31\uff0c\u7528\u8ba1\u7b97\u5668\u8ba1\u7b97\u51fa\u8fd9\u4e2a\u6570\u662f\uff1a00\u3002\u53ef\u4ee5\u628a\u4e0a\u8ff0\u7a0b\u5e8f\u4e2d\u7684for\u5faa\u73af\u4e2d\u7684i\u521d\u59cb\u5316\u6210\u8fd9\u4e2a\u6570\u6765\u68c0\u9a8c\u3002<\/span><\/p>\n

          <\/p>\n

          2.21 \u53ea\u8003\u52a0\u6cd5\u7684\u9762\u8bd5\u9898<\/p>\n

          \u53c2\u8003:http:\/\/blog.csdn.net\/yutianzuijin\/article\/details\/\/\/  by zjerry \u8fd9\u7bc7\u7a0d\u597d\u7406\u89e3<\/p>\n

          http:\/\/www.cnblogs.com\/peteryj\/archive\/2009\/07\/08\/1944889.html <\/p>\n

          http:\/\/blog.csdn.net\/lyso1\/article\/details\/ <\/p>\n

          http:\/\/www.cnblogs.com\/flyinghearts\/archive\/2011\/03\/27\/1997285.html <\/p>\n

          <\/p>\n

          3.1 \u5b57\u7b26\u4e32\u79fb\u4f4d\u5305\u542b\u7684\u95ee\u9898<\/p>\n

          \u65b9\u6cd51\u662f\u5c06\u6e90\u4e32\u8fdb\u884c\u5faa\u73af\u79fb\u4f4d,\u7136\u540e\u6309\u9898\u76ee\u76f4\u63a5\u610f\u601d\u53bb\u5224\u65ad\u662f\u5426\u5305\u542b,\u5faa\u73af\u79fb\u4f4d\u9700\u8981O(N*N),\u5339\u914d\u81f3\u5c11\u8981O(M+N)<\/p>\n

          \u65b9\u6cd52\u662f\u53d1\u73b0\u5faa\u73af\u79fb\u4f4d\u7684\u7ec8\u6001\u53ef\u4ee5\u7528\u4e24\u4e2a\u6e90\u4e32\u7684\u62fc\u63a5\u6765\u4f5c\u65b0\u7684\u6bd4\u8f83\u4e32,\u8f6c\u5316\u4e3a\u5b57\u7b26\u4e32\u6a21\u5f0f\u5339\u914d,\u4f46\u662f\u589e\u52a0\u4e86\u7a7a\u95f4\u590d\u6742\u5ea6<\/p>\n

          \u6269\u5c55:<\/p>\n

          \u4e0d\u9700\u8981\u7533\u8bf7\u989d\u5916\u7a7a\u95f4:\u53ef\u4ee5\u6539\u8fdb\u6a21\u5f0f\u5339\u914d\u7684\u957f\u5ea6\u4e3a2*length(s1),\u800c\u6b65\u8fdb\u7684\u89c4\u5f8b\u4e5f\u6539\u4e3a(i+1)%length(s1),\u6700\u7ec8\u7528KMP\u7b49\u7b97\u6cd5\u6539\u8fdb\u4e3aO(M+N)<\/p>\n

          <\/p>\n

          3.2 \u7535\u8bdd\u53f7\u7801\u5bf9\u5e94\u82f1\u8bed\u5355\u8bcd<\/p>\n

          \u76f4\u63a5\u770b\u95ee\u98981\u548c2,\u53d1\u73b0,\u90fd\u662f\u8981\u5148\u505a\u6620\u5c04\u7136\u540e,\u5339\u914d\u5b57\u6bcd\u7ec4\u5408\u662f\u5426\u662f\u771f\u7684\u5355\u8bcd,<\/p>\n

          \u7ed3\u679c\u770b\u4e86\u4e66\u4e2d\u89e3\u6cd5\u53d1\u73b0,\u4e66\u4e2d\u5199\u89e3\u6cd5\u7684\u4eba\u4f3c\u4e4e\u6ca1\u8bfb\u61c2\u9898\u76ee,\u6216\u8005\u6ca1\u8bfb\u5b8c\u5168<\/p>\n

          \u95ee\u98981\u6211\u8ba4\u4e3a\u7b80\u5355\u63cf\u8ff0\u6210:\u6839\u636e\u4e00\u4e2a\u53f7\u7801,\u5982\u679c\u5c3d\u53ef\u80fd\u5feb\u5730\u4ece\u5176\u5b57\u6bcd\u7ec4\u5408\u4e2d\u627e\u51fa\u6709\u610f\u4e49\u7684\u5355\u8bcd<\/p>\n

          \u95ee\u98982\u6211\u8ba4\u4e3a\u53ef\u4ee5\u63cf\u8ff0\u6210:\u95ee\u98981\u662f\u5426\u6709\u7b54\u6848....(\u5b9e\u5728\u770b\u4e0d\u51fa\u8fd8\u80fd\u600e\u4e48\u65ad\u53e5\u4e86....)<\/p>\n

          \u5728\u4e66\u4e2d\u89e3\u6cd5\u7684\u57fa\u7840\u4e0a(\u904d\u5386\u6216\u9012\u5f52\u5f97\u5230\u7535\u8bdd\u4e2d\u6570\u5b57\u6309\u4e0b\u540e\u5b57\u6bcd\u7684\u6240\u6709\u7ec4\u5408),\u5728\u6bcf\u4e2a\u5b57\u6bcd\u7ec4\u5408\u4e0a\u90fd\u67e5\u4e00\u904d\u5355\u8bcd\u5b57\u5178\u8868,\u8f93\u51fa\u6709\u610f\u4e49\u7684\u5355\u8bcd,\u8fd9\u5f53\u7136\u4e0d\u662f\u5c3d\u53ef\u80fd\u5feb\u7684\u65b9\u6cd5\u4e86,\u67e5\u8be2\u4e00\u4e2a\u6570\u5b57\u5bf9\u5e94\u7684\u7ec4\u5408\u6709O(3^N)(\/\/ \u9664\u4e867,9\u5bf9\u5e94\u662f4\u4f4d),\u67e5\u8be2\u5b57\u5178\u6709O(LOGMAX),\u6700\u7ec8\u662f\u6bcf\u6b21\u67e5\u8be2O(3^N*LOGMAX)<\/p>\n

          \u89e3\u51b3\u65b9\u6cd5\u662f:<\/p>\n

          \u5c06\u5355\u8bcd\u5b57\u5178\u8868\u6bcf\u4e2a\u5355\u8bcd\u90fd\u5148\u8f6c\u5316\u4e3a\u6570\u5b57\u6620\u5c04O(N)\/\/N\u662f\u5355\u8bcd\u5b57\u6bcd\u6570\u91cf,\u6bcf\u6b21\u67e5\u8be2O(LOGMAX)<\/p>\n

          <\/p>\n

          3.3 \u8ba1\u7b97\u5b57\u7b26\u4e32\u7684\u76f8\u4f3c\u5ea6<\/p>\n

          \u9012\u5f52\u6c42\u76f8\u4f3c\u5ea6\uff0c\u9012\u5f52\u4e2d\u4f1a\u6709\u91cd\u590d\u8ba1\u7b97\uff0c\u9700\u8981\u4fdd\u5b58\u8bb0\u5f55<\/p>\n

          \u53c2\u8003\uff1ahttp:\/\/www.cnblogs.com\/yujunyong\/articles\/2004724.html <\/p>\n

          \u52a8\u6001\u89c4\u5212\u81ea\u5e95\u5411\u4e0a\uff0c\u6216\u8005\u5907\u5fd8\u5f55\u81ea\u9876\u5411\u4e0b<\/p>\n

          <\/p>\n

          3.4 \u4ece\u65e0\u5934\u5355\u94fe\u8868\u4e2d\u5220\u9664\u8282\u70b9<\/p>\n

          \u8282\u70b9\u5220\u9664\u9700\u8981\u77e5\u9053\u524d\u9a71,\u60f3\u5728O(1) \u7684\u60c5\u51b5\u4e0b\u5220\u9664\u5c31\u53ea\u80fd\u5220\u9664\u5f53\u524d\u8282\u70b9\u7684\u6570\u636e,\u800c\u5b9e\u9645\u4e0a\u5220\u9664\u4e0b\u4e00\u7ed3\u70b9\u7684\u7a7a\u95f4,\u5220\u9664\u524d\u628a\u4e0b\u4e00\u8282\u70b9\u7684\u6570\u636e\u590d\u5236\u8fc7\u6765<\/p>\n

          \u6269\u5c55\u95ee\u9898<\/p>\n

          \u4e00\u6b21\u904d\u5386,\u9006\u7f6e\u5355\u94fe\u8868<\/p>\n

          \u6570\u7ec4\u4e2d\u9006\u7f6e\u7684\u539f\u7406\u662f\u5c06\u6570\u636e\u4e0d\u65ad\u4ea4\u6362\u8fc7\u6765(\u56e0\u4e3a\u5728\u5e8f\u5b58\u50a8\u7a7a\u95f4\u5206\u914d\u540e\u662f\u56fa\u5b9a\u7684)<\/p>\n

          \u94fe\u8868\u4e2d\u9006\u7f6e\u5219\u53ef\u4ee5\u4e0d\u4ea4\u6362\u6570\u636e,\u53ea\u4fee\u6539\u94fe\u63a5\u7684\u7ed3\u6784\u6765\u5b9e\u73b0\u7269\u7406\u4e0a\u7684\u9006\u7f6e,\u5177\u4f53\u5b9e\u73b0\u9700\u8981\u501f\u52a9\u4e09\u4e2a\u6307\u9488,\u4e0d\u505c\u5c06P2\u6307\u5411P1<\/p>\n

          <\/p>\n

          3.5 \u6700\u77ed\u6458\u8981\u7684\u751f\u6210<\/p>\n

          \u6211\u7684\u7406\u89e3\u5c31\u662f\u6ed1\u52a8\u7a97\u53e3,\u9010\u6e10\u7f29\u5c0f\u6bcf\u4e2a\u6458\u8981\u6bb5\u843d\u533a\u95f4,\u4ece\u800c\u6c42\u5f97\u6700\u77ed\u6458\u8981,\u65f6\u95f4\u590d\u6742\u5ea6\u53ef\u4ee5\u4f18\u5316\u5230O(M*LOGN*N)\/\/ by zjerry \u5e94\u8be5\u8fd8\u80fd\u7ee7\u7eed\u4f18\u5316,\u6211\u60f3\u7684\u592a\u7b80\u5355\u4e86?<\/p>\n

          \u6269\u5c55\u95ee\u9898:<\/p>\n

          LCS\u76f8\u4f3c\u68c0\u6d4b<\/p>\n

          <\/p>\n

          3.6 \u7f16\u7a0b\u5224\u65ad\u4e24\u4e2a\u94fe\u8868\u662f\u5426\u76f8\u4ea4<\/p>\n

          \u5224\u65ad\u6700\u540e\u4e00\u4e2a\u8282\u70b9\u662f\u5426\u76f8\u540c<\/p>\n

          \u6269\u5c55\u95ee\u9898<\/p>\n

          1,\u5982\u679c\u94fe\u8868\u6709\u73af,\u4e24\u79cd\u60c5\u51b5,\u4ea4\u70b9\u5728\u73af\u4e0a,\u4ea4\u70b9\u5728\u5c3e\u5df4\u4e0a,\u4e24\u79cd\u60c5\u51b5\u7684\u5224\u65ad\u65b9\u6cd5\u90fd\u662f:<\/p>\n

          \u5148\u5229\u7528\u5feb\u6162\u6cd5\u627e\u5230\u4e00\u4e2a\u94fe\u8868\u7684\u78b0\u649e\u70b9,\u5728\u73af\u5185,\u7136\u540e\u904d\u5386\u53e6\u5916\u4e00\u4e2a\u94fe\u8868,\u904d\u5386\u8fc7\u7a0b\u4e2d\u5224\u65ad\u662f\u5426\u4e0e\u78b0\u649e\u70b9\u76f8\u540c<\/p>\n

          2.\u6c42\u51fa\u4ea4\u70b9:<\/p>\n

          \u65e0\u73af\u94fe\u8868\u5229\u7528\u6c42\u4e24\u94fe\u8868\u957f\u5ea6\u5dee,\u7136\u540e\u5148\u540e\u8d70<\/p>\n

          \u6709\u73af\u94fe\u88681\u4ea4\u70b9\u5728\u73af\u4e0a,\u5404\u81ea\u6c42\u51fa\u73af\u7684\u5165\u53e3,2\u4ea4\u70b9\u5728\u5c3e\u5df4\u4e0a,\u4e0e\u65e0\u73af\u94fe\u8868\u4e00\u6837\u6c42\u94fe\u8868\u957f\u5ea6\u5dee<\/p>\n

          <\/p>\n

          3.7 \u961f\u5217\u4e2d\u53d6\u6700\u5927\u503c\u64cd\u4f5c\u95ee\u9898<\/p>\n

          \u95ee\u9898\u57fa\u4e8e:\u6808\u4e2d\u53d6\u6700\u503c\u95ee\u9898<\/p>\n

          <\/p>\n

          3.8 \u6c42\u4e8c\u53c9\u6811\u4e2d\u8282\u70b9\u7684\u6700\u5927\u8ddd\u79bb<\/p>\n

          max(maxleft,maxright,height_left+heigth_right);\/\/\u5de6\u5b69\u5b50\u7684\u6700\u5927\u8ddd\u79bb\uff0c\u53f3\u5b69\u5b50\u7684\u6700\u5927\u8ddd\u79bb\uff0c\u5de6\u5b50\u6811\u7684\u9ad8\u5ea6+\u53f3\u5b50\u6811\u7684\u9ad8\u5ea6<\/p>\n

          <\/p>\n

          3.9 \u91cd\u5efa\u4e8c\u53c9\u6811<\/p>\n

          <\/p>\n

          3.10 \u5206\u5c42\u904d\u5386\u4e8c\u53c9\u6811<\/p>\n

          BFS\u5229\u7528\u961f\u5217\u904d\u5386<\/p>\n

          \u6269\u5c55\u95ee\u9898<\/p>\n

          1.BFS\u904d\u5386\uff08\u5148\u8bbf\u95ee\u53f3\u5b69\u5b50\uff09\u6570\u636e\u5165\u6808\uff0c\u4e00\u5c42\u5b8c\u7ed3\u65f6\u4f5c\u5c42\u6807\u8bb0\u5165\u6808\uff0c\u5168\u90e8\u5b8c\u6210\u518d\u51fa\u6808<\/p>\n

          2.BFS\u904d\u5386\uff08\u5148\u8bbf\u95ee\u5de6\u5b69\u5b50\uff09\u6570\u636e\u5165\u6808\uff0c\u4e00\u5c42\u5b8c\u7ed3\u65f6\u4f5c\u5c42\u6807\u8bb0\u5165\u6808\uff0c\u5168\u90e8\u5b8c\u6210\u518d\u51fa\u6808<\/p>\n

          <\/p>\n

          <\/p>\n

          3.11 \u7a0b\u5e8f\u6539\u9519<\/p>\n

          \u4e8c\u5206\u67e5\u627e<\/p>\n

          <\/p>\n

          <\/p>\n


          <\/span><\/p>\n

          \n

          <\/p>\n

          4.1\u91d1\u521a\u5750\u98de\u673a\u95ee\u9898<\/p>\n

          \u95ee\u98982\u7684\u89e3\u6cd5\u672a\u5b8c\u5168\u7406\u89e3\u548c\u638c\u63e1<\/p>\n

          \u6269\u5c551<\/p>\n

          \u6bcf\u4e2a\u4e58\u5ba2\u5305\u62ec\u91d1\u521a\u90fd\u662f\u968f\u673a\u9009\u4f4d\u7f6e,\u6240\u4ee5\u7b54\u6848\u4f9d\u7136\u662f1\/N<\/p>\n

          \u6269\u5c552<\/p>\n

          \u5206\u60c5\u51b5\u8ba8\u8bba<\/p>\n

          i\u4e0d\u53ef\u80fd\u662f1,\u56e0\u4e3a\u91d1\u521a\u5148\u5165\u5ea7<\/p>\n

          i=2\u65f6, \u53ea\u8981\u91d1\u521a\u4e0d\u9009\u4e2d\u7b2ci\u4e2a\u4eba\u7684\u5ea7\u4f4d,\u5047\u8bbe\u662fx,\u6240\u4ee5\u6982\u7387\u662f  n-1\/n<\/p>\n

          i=3\u65f6,\u91d1\u521a\u9009\u4e2d\u7b2c2\u4eba\u5ea7\u4f4d,\u7b2c2\u4eba\u4e0d\u9009x;\u53e6\u5916\u4e00\u79cd\u60c5\u5f62\u662f\u91d1\u521a\u672a\u9009\u7b2c2\u4eba\u672a\u9009x,\u7b2c2\u4eba\u9009\u81ea\u5df1\u7684,\u7136\u540e\u52a0\u6cd5\u539f\u7406<\/p>\n

          i=4\u65f6,\u7c7b\u4f3c\u4e0a\u8ff0<\/p>\n

          <\/p>\n

          4.2\u74f7\u7816\u8986\u76d6\u5730\u677f<\/p>\n

          \u6269\u5c551<\/p>\n

          \u6590\u6ce2\u90a3\u5207\u6570\u5217<\/p>\n

          \u63a8\u5e7f1<\/p>\n

          DP\u95ee\u9898\u6682\u65f6\u6ca1\u5f7b\u5e95\u5f04\u660e\u767d<\/p>\n

          \u63a8\u5e7f2<\/p>\n

          \n

          \n \u89e3\uff1a\n<\/div>\n
          \n \u2460M*N\u5fc5\u987b\u662fp*q\u7684\u6574\u6570\u500d\n<\/div>\n
          \n \u2461p\u548cq\u4e2d\u5927\u6570\u8981\u5c0f\u4e8e\u7b49\u4e8eM\uff0cN\u7684\u5927\u6570\uff0c\u5c0f\u6570\u8981\u5c0f\u4e8e\u7b49\u4e8eM,N\u7684\u5c0f\u6570\n<\/div>\n
          \n \u2462\u5982\u679cp*q\u662f\u5076\u6570\uff0c\u90a3\u4e48M,N\u5f53\u4e2d\u4e0d\u662fp,q\u500d\u6570\u7684\u8fb9\u957f\uff0c\u5fc5\u987b\u662fp\u548cq\u7684\u67d0\u79cd*+\u8fd0\u7b97\u7ec4\u5408\uff1b\n<\/div>\n
          \n   \u5982\u679c\u662f\u5947\u6570\uff0c\u90a3\u4e48\u53ea\u9700\u8981\u6ee1\u8db3\u524d\u4e24\u4e2a\u6761\u4ef6\u5373\u53ef <\/p>\n

          4.3\u4e70\u7968\u627e\u96f6\n<\/p><\/div>\n

          \n \u6269\u5c55\n<\/div>\n
          \n \u5168\u90e8\u662fCatalan\u6570\u7684\u5e94\u7528\u95ee\u9898\n<\/div>\n
          \n \u89e3\u51b3\u7684\u601d\u8def\u5728\u4e8e\u627e\u5230\u7b2ck\u4e2a,\u5c06\u95ee\u9898\u8f6c\u5316\u4e3a1\u5230k-1,  k+1\u5230n\u4e24\u90e8\u5206,\u7136\u540e\u5206\u522b\u7528\u4e58\u6cd5\u539f\u7406\u548c\u52a0\u6cd5\u539f\u7406,\u5f97\u5230\u63a8\u5bfc\u516c\u5f0f;\n<\/div>\n
          \n \u4e3b\u8981\u662f\u7406\u89e3Catalan\u6570\u7684\u6982\u5ff5,\u4e00\u534a+1\u4e0e\u4e00\u534a-1\u7ec4\u6210\u7684\u6570\u5217,\u4fdd\u8bc1\u6392\u5217\u540e\u7684\u548c>=0,\u5219\u6392\u5217\u5f62\u5f0f\u7684\u4e2a\u6570\u5373\u4e3aCatalan\u6570\n<\/div>\n
          \n
          \n<\/div>\n
          \n 4.4\u70b9\u662f\u5426\u5728\u4e09\u89d2\u5f62\u5185\n<\/div>\n
          \n \u65b9\u6cd5\u4e00\u9762\u79ef\u6cd5\n<\/div>\n
          \n \u65b9\u6cd5\u4e8c\u53c9\u4e58\u5224\u522b\u6cd5\n<\/div>\n
          \n \u6269\u5c55\n<\/div>\n
          \n \u4e0d\u5305\u62ec\u70b9\u5728\u8fb9\u4e0a,\u53ef\u4ee5\u5c06\u70b9\u8fb9\u4e24\u4e2a\u9876\u70b9\u6784\u6210\u7684\u5411\u91cf\u8ba1\u7b97\u662f\u5426\u5e73\u884c\u6765\u5224\u65ad\u662f\u5426\u5728\u8fb9\u4e0a(\u4f46\u8fd9\u91cc\u4e5f\u6709\u6d6e\u70b9\u7c7b\u578b\u7684\u8bef\u5dee\u95ee\u9898)\n<\/div>\n
          \n \u5176\u5b9e\u5982\u679c\u8ba4\u4e3a\u65e0\u8bef\u5dee,\n<\/div>\n
          \n \u9762\u79ef\u6cd5\u4e2d\u5224\u65ad\u67d0\u4e2a\u4e09\u89d2\u5f62\u9762\u79ef\u4e3a0\u5373\u5728\u8fb9\u4e0a\n<\/div>\n
          \n \u53c9\u4e58\u5224\u522b\u6cd5\u4e2d\u5224\u65ad\u67d0\u4e2a\u79ef\u4e3a0\u5373\u5728\u8fb9\u4e0a\n<\/div>\n
          \n
          \n<\/div>\n
          \n \u6269\u5c55\u4e4b\u5224\u65ad\u70b9\u662f\u5426\u5728\u591a\u8fb9\u5f62\u5185\n<\/div>\n
          \n
          \n<\/div>\n
          \n \u4e94\u79cd\u65b9\u6cd5(\u8fd8\u6ca1\u5b8c\u5168\u7406\u89e3)\n<\/div>\n
          \n http:\/\/www.cnblogs.com\/lzjsky\/archive\/2011\/06\/20\/2085314.html
          \n
          http:\/\/wenku.baidu.com\/link?url=HbLXTFZks-5BM6oA8GOcFWLRAcPSWtUC55OgF35-XRJfVNNCYpYFucTULwGG1OyHZgWCIdBbOdiowdeOSDYQ-2rtQCRWtH-Ts8yPjwRytZW\n<\/div>\n
          \n http:\/\/www.cnblogs.com\/hhyypp\/archive\/2011\/12\/05\/2276984.html\n<\/div>\n
          \n http:\/\/blog.csdn.net\/hgl868\/article\/details\/\n<\/div>\n
          \n http:\/\/blog.163.com\/liling2009@126\/blog\/static\/84\/
          \n <\/p>\n

          \n

          4.5\u78c1\u5e26\u6587\u4ef6\u5b58\u653e\u4f18\u5316\n<\/p><\/div>\n

          \n
          \n<\/div>\n
          \n \u5982\u679c\u6587\u4ef6\u957f\u5ea6\u548c\u88ab\u8bbf\u95ee\u6982\u7387\u90fd\u4e0d\u540c,\u9009\u62e9P\/L\u4ece\u5927\u5230\u5c0f\u6392\u5217\u53ef\u4ee5\u5f97\u5230\u6700\u4f73\u5b58\u50a8\u987a\u5e8f,\u4e66\u4e2d\u7528\u7684\u5b9e\u4f8b\u63a8\u5bfc\u7684\u7ed3\u8bba,\u662f\u5426\u6709\u901a\u7528\u6027\u5462?\n<\/div>\n
          \n
          \n<\/div>\n
          \n 4.6\u6876\u4e2d\u53d6\u9ed1\u767d\u7403\n<\/div>\n
          \n
          \n<\/div>\n
          \n \u5bf9\u5947\u5076\u7684\u6027\u8d28\u5224\u65ad\n<\/div>\n
          \n \u5bf9\u52a0\u51cf\u6cd5\u7684\u5e94\u7528\n<\/div>\n
          \n \u5bf9\u5f02\u6216\u7684\u5e94\u7528\n<\/div>\n
          \n
          \n<\/div>\n
          \n \u6269\u5c55\u95ee\u9898\n<\/div>\n
          \n 2\u9ed1\u767d\u6570\u76ee\u4e0d\u5b9a,\u6839\u636e\u5dee\u503c\u548c\u6570\u76ee\u5c0f\u7684\u6570,\u8fd9\u4e24\u4e2a\u6570\u5b57\u7684\u5947\u5076\u5173\u7cfb\u5f97\u5230\u6700\u7ec8\u7ed3\u679c\n<\/div>\n
          \n
          \n<\/div>\n
          \n 4.7\u8682\u8681\u722c\u6746\n<\/div>\n
          \n \u79bb\u7aef\u70b9\u6700\u8fdc\u7684\u8682\u8681\u5373\u662f\u63a7\u5236\u5168\u90e8\u79bb\u5f00\u65f6\u95f4\u6700\u957f\u7684\u90a3\u4f4d(\u5176\u4ed6\u5411\u8fd1\u8fdc\u7aef\u79bb\u5f00\u90fd\u65e0\u6240\u8c13,\u8fd9\u4f4d\u5411\u6700\u8fdc\u79bb\u5f00)\n<\/div>\n
          \n \u79bb\u4e2d\u70b9\u6700\u8fd1\u7684\u8682\u8681\u5373\u662f\u63a7\u5236\u5168\u90e8\u79bb\u5f00\u65f6\u95f4\u6700\u77ed\u7684\u90a3\u4f4d(\u5176\u4ed6\u5747\u5411\u8fd1\u7aef\u79bb\u5f00,\u8fd9\u4f4d\u5411\u8fd1\u7aef\u79bb\u5f00)\n<\/div>\n
          \n
          \n<\/div>\n
          \n \u6269\u5c55\u95ee\u9898\n<\/div>\n
          \n http:\/\/lam8da.sinaapp.com\/?p=11
          \n
          \n<\/div>\n
          \n \u7f16\u7a0b\u4e4b\u7f8e----\u6269\u5c55\u95ee\u9898
          \n
          \n<\/div>\n
          \n 1\n<\/div>\n
          \n 2\n<\/div>\n
          \n 3\n<\/div>\n
          \n 4\n<\/div>\n
          \n 5\n<\/div>\n
          \n
          \n<\/div>\n
          \n 4.8\u4e09\u89d2\u5f62\u6d4b\u8bd5\u7528\u4f8b\n<\/div>\n
          \n
          \n<\/div>\n
          \n \u4e00\u822c\u60c5\u51b5\u4e0b\u6d4b\u8bd5\u7684\u51e0\u4e2a\u65b9\u9762:\n<\/div>\n
          \n \u6b63\u5e38\u8f93\u5165\u7684\u529f\u80fd\u6d4b\u8bd5\n<\/div>\n
          \n \u975e\u6cd5\u8f93\u5165\u7684\u5f02\u5e38\u53cd\u9988\n<\/div>\n
          \n \u8fb9\u754c\u8f93\u5165\u7684\u5904\u7406\u6548\u679c\n<\/div>\n
          \n
          \n<\/div>\n
          \n \u6269\u5c551\n<\/div>\n
          \n \u6539\u4e3a\u6d6e\u70b9\u6570\u540e,\u4e3b\u8981\u662f\u8bbe\u7f6e\u53ef\u63a5\u53d7\u7cbe\u5ea6,\n<\/div>\n
          \n \u7279\u522b\u5728\u76f8\u7b49\u8fb9\u4e0a\u7684\u5224\u65ad,\n<\/div>\n
          \n \u5982\u7b49\u8170,\u7b49\u8fb9\n<\/div>\n
          \n
          \n<\/div>\n
          \n \u6269\u5c552\n<\/div>\n
          \n \u53e6\u5b58\u4e3a\u7684\u529f\u80fd\n<\/div>\n
          \n \u6b63\u5e38SAVE AS\u7684\u7528\u4f8b\u8fc7\u7a0b:\n<\/div>\n
          \n \u9009\u62e9\u53ef\u4fdd\u5b58\u7684\u76ee\u5f55\u8def\u5f84(\u663e\u793a\u76f8\u5bf9\u8def\u5f84\u6216\u7edd\u5bf9\u8def\u5f84),\u8f93\u5165\u7cfb\u7edf\u53ef\u63a5\u53d7\u7684\u6587\u4ef6\u540d,\u4fdd\u5b58\u4e3aWORD\u5bf9\u5e94\u683c\u5f0f\u7684\u6269\u5c55\u540d\u6587\u4ef6,\u91cd\u65b0\u6253\u5f00\u8be5\u6587\u4ef6\u6570\u636e\u65e0\u5dee\u5f02\n<\/div>\n
          \n \u975e\u6cd5\u8f93\u5165\n<\/div>\n
          \n \u9009\u62e9\u65e0\u6743\u9650\u7684\u8def\u5f84\u6709\u63d0\u793a,\u8def\u5f84\u4e0b\u7a7a\u95f4\u4e0d\u8db3\u6709\u63d0\u793a,\u8f93\u5165\u975e\u6cd5\u6587\u4ef6\u540d\u6709\u63d0\u793a,\u8f93\u5165\u540c\u540d\u6587\u4ef6\u63d0\u793a\u662f\u5426\u8986\u76d6,\u8f93\u5165\u5176\u4ed6\u6269\u5c55\u540d\u6709\u63d0\u793a\n<\/div>\n
          \n \u8fb9\u754c\u8f93\u5165\n<\/div>\n
          \n \u6682\u65f6\u6ca1\u60f3\u5230\u8fd9\u79cd\u6d4b\u8bd5,\u600e\u4e48\u6837\u7b97\u662f\u8fb9\u754c\n<\/div>\n
          \n
          \n<\/div>\n
          \n
          \n<\/div>\n
          \n 4.9\u6570\u72ec\u77e5\u591a\u5c11\n<\/div>\n
          \n \u53c2\u8003\u8bba\u6587\uff1a\n<\/div>\n
          \n http:\/\/www.afjarvis.staff.shef.ac.uk\/sudoku\/felgenhauer_jarvis_spec1.pdf
          \n
          \n<\/div>\n
          \n \u6269\u5c55\u95ee\u9898\uff1a\n<\/div>\n
          \n \u6700\u7b80\u5355\u7684\u60f3\u6cd5\u5c31\u662f\u75280\u8868\u793a\u7a7a\u683c\uff0c\u56e0\u4e3a\u6570\u72ec\u53ea\u7528\u4e861-9,\u8fdb\u4e00\u6b65\u538b\u7f29\u53ef\u4ee5\u589e\u52a0\u8f6c\u4e49\u7b26\u53f7\uff0c0\u8868\u793a\u4e00\u4e2a\u7a7a\u683c\uff0c\/20\u8868\u793a\u4e24\u4e2a\uff0c\u589e\u52a0\u4e86\u4e24\u4e2a\u7b26\u53f7\uff0c\u6216\u8005\u7528\u5b57\u6bcd\uff0c\u4e0e\u6570\u5b57\u4e0d\u4ea7\u751f\u51b2\u7a81,\u6bd4\u59820\u8868\u793a\u4e00\u4e2a\u7a7a\u683c\uff0cB0\u8868\u793a\u4e24\u4e2a\u7a7a\u683c\n<\/div>\n
          \n
          \n<\/div>\n
          \n 4.10\u6570\u5b57\u54d1\u8c1c\u548c\u56de\u6587
          \n
          http:\/\/wenku.baidu.com\/link?url=2xnIFfvaVYedENAqdWn-BhaqNwkoZJhZczE-15IdXG5YGL-3BFGrj-JZQLy8Tv2F_PZhBVt440r--2hSDEJa8SqS2bgLiV6yfHxWHApa9Ba
          \n
          \n<\/div>\n
          \n \/\/ \u67d0\u4e2a\u6574\u6570\u80fd\u88ab1,2,3-9\u5176\u4e2d\u7684\u67d0\u4e2a\u6570\u5b57\u6574\u9664\u7684\u901a\u7528\u89c4\u5f8b:\u5c06\u6570abcdefg\u5199\u6210abc*10000+defg(\u5047\u8bbe\u53ef\u4ee5\u88ab10001\u6574\u9664),\u7136\u540eabc*10001+defg-abc,\u6700\u540e\u5229\u7528defg-abc\u53ef\u4ee5\u6574\u9664\u8be5\u6570\u5b57\u6765\u7b80\u5316\u8ba1\u7b97\n<\/div>\n
          \n
          \n<\/div>\n
          \n \u6269\u5c551\n<\/div>\n
          \n N\u4f4d\u56de\u6587\u6570\u6709\u591a\u5c11\u4e2a?\n<\/div>\n
          \n \u8f6c\u4e3a\u5230\u7684\u95ee\u9898\u662f(N+1)\/2\u4f4d\u7684\u6570\u5b57\u6709\u591a\u5c11\u4e2a,\u6bd4\u5982\u8bf46\u4f4d\u6570\u548c5\u4f4d\u6570\u7684\u56de\u6587\u6570\u90fd=3\u4f4d\u6570\u7684\u6570\u5b57\u4e2a\u6570900\n<\/div>\n
          \n \u6269\u5c552\n<\/div>\n
          \n 25^2=625\n<\/div>\n
          \n \u95ee\u98982\u7684\u63a8\u5e7f\n<\/div>\n
          \n \u5176\u4ed6\u8fdb\u5236\u4e0a\u6570\u5b57\u7b49\u5f0f\u7684\u63a8\u6d4b....\u6682\u65f6\u6ca1\u601d\u8003,\u9664\u4e86\u4e8c\u8fdb\u5236,\u5341\u8fdb\u5236,\u5176\u4ed6\u7684\u90fd\u5934\u75bc...\n<\/div>\n
          \n
          \n<\/div>\n
          \n 4.11\u626b\u96f7\u6e38\u620f\u7684\u6982\u7387\n<\/div>\n
          \n \u53c2\u8003\uff1a\n<\/div>\n
          \n \u7f16\u7a0b\u4e4b\u7f8e----\u6269\u5c55\u95ee\u9898
          \n
          \n<\/div>\n
          \n http:\/\/www.cnblogs.com\/easymind223\/archive\/2012\/07\/04\/2576934.html
          \n
          \n<\/div>\n
          \n \u7f16\u7a0b\u4e4b\u7f8e----\u6269\u5c55\u95ee\u9898
          \n
          \n<\/div>\n
          \n \u95ee\u98981\n<\/div>\n
          \n \u4f7f\u7528\u53e4\u5178\u6982\u7387\uff0c\u800c\u4e0d\u662f\u6761\u4ef6\u6982\u7387\u5168\u6982\u7387\uff0c\u56e0\u4e3a\u5b50\u96f7\u533a\u96f7\u6570\u7684\u6982\u7387\u4e0d\u597d\u6c42\n<\/div>\n
          \n \u95ee\u98982\n<\/div>\n
          \n \u95ee\u98981\u89e3\u51fa\u6765\u540e\u53ef\u4ee5\u7528MATLAB\u5212\u79bb\u6563\u56fe\u5f62\uff0c\u8be6\u7ec6\u89c1\u53c2\u80033\n<\/div>\n
          \n
          \n<\/div>\n


          <\/p>\n

          \n

          \n

          1.11 NIM(1)\u4e00\u6392\u77f3\u5934\u7684\u6e38\u620f<\/p>\n

          \u6ce8\u660eA\u5148\u53d6,B\u540e\u53d6<\/p>\n

          \u6269\u5c55<\/p>\n

          1.N=3K+1(K=0\uff0c1\uff0c2\uff0c\u2026\u2026\uff09\u65f6\u5148\u53d6\u8005A\u8f93\uff0c\u5176\u4f59\u60c5\u51b5N=3K,N=3K+2\u65f6\u5148\u53d6\u8005A\u8d62<\/span><\/p>\n

          \u7f16\u7a0b\u4e4b\u7f8e----\u6269\u5c55\u95ee\u9898 <\/p>\n

          http:\/\/hi.baidu.com\/hehehehello\/item\/4115b9151a2f29fd756a8487 <\/p>\n

          2.N%(K+1)=0\u65f6\uff0c\u73a9\u5bb6B\u6709\u5fc5\u80dc\u7b56\u7565\uff0cN%(K+1)!=0\u65f6\uff0c\u73a9\u5bb6A\u6709\u5fc5\u80dc\u7b56\u7565\u3002<\/p>\n

          \u5f53d=0\u65f6\uff0c\u65e0\u8bbaA\u53d6\u591a\u5c11\u4e2a\u77f3\u5934\uff0cB\u53d6\u76f8\u5e94\u7684\u77f3\u5934\uff0c\u4f7f\u5f97A\u548cB\u4e00\u8d77\u53d6(K+1)\u4e2a\u77f3\u5934\uff0c\u8fd9\u6837\u6700\u540e\u53d6\u5230\u77f3\u5934\u7684\u80af\u5b9a\u662f\u73a9\u5bb6B\u3002 <\/p>\n

          <\/p>\n

          1.12 NIM(2)\"\u62c8\"\u6e38\u620f\u5206\u6790<\/p>\n

          \u6ce8\u660eA\u5148\u5206\u914d,B\u5148\u53d6,A\u540e\u53d6<\/p>\n

          http:\/\/www.cnblogs.com\/yintingru\/archive\/2012\/08\/27\/2658483.html <\/p>\n

          \u53d6\u77f3\u5934\u7684\u8fc7\u7a0b\u4e0e\u4e0a\u4e00\u6b21\u4ed6\u4eba\u53d6\u7684\u6570\u76ee\u59cb\u7ec8\u4fdd\u6301\u4e00\u4e2a\"\u5b89\u5168\u7684\u72b6\u6001\",\u5373\u53ef\u4ee5\u786e\u4fdd\u5b8c\u80dc,\u8fd9\u91cc\u5b89\u5168\u7684\u72b6\u6001\u662fXOR\u4e3a0<\/p>\n

          \u6269\u5c55\u95ee\u9898<\/p>\n

          1\u5982\u679c\u53d6\u5149\u8005\u8f93,\u5f53N=2,B\u5148\u53d6,A\u5fc5\u8f93,N>2,A\u5fc5\u80dc,\u53ea\u8981\u786e\u4fdd\u5806\u6570\u4e3a\u5947,\u4e2a\u6570\u4e5f\u4e3a\u5947\u5373\u53ef,N\u4e3a\u5947\u6570,\u5219\u5206\u914d(1,1,1,...),N\u4e3a\u5076\u6570,\u5219\u5206\u914d(N\/2,N\/2)<\/p>\n

          2\u82e5\u662f\u5148\u53d6\u5149\u8005\u80dc,\u5219A\u4fdd\u6301\u5b89\u5168\u72b6\u6001\u4e3a\u6bcf\u6b21\u53d6\u8d70\u548c\u4e3aK+1(\u4e0e1.11\u6269\u5c55\u95ee\u9898\u7c7b\u4f3c),\u4e14\u6bcf\u5806\u7684\u4e2a\u6570\u4e3a>=2(\u5173\u952e\u662f\u53d6\u5230\u53ea\u5269\u4e0bK+1,K+2...K+K-1\u5806\u65f6\u7684\u6289\u62e9\u95ee\u9898\u4e0a)<\/p>\n

          \/\/ by zjerry \u672a\u4ed4\u7ec6\u8ba4\u8bc1,\u5148\u5230\u8fd9\u91cc<\/p>\n

          <\/p>\n

          1.13 NIM(3)\u4e24\u5806\u77f3\u5934\u7684\u6e38\u620f<\/p>\n

          \u6ce8\u610fA\u5148\u53d6, B\u540e\u53d6,AB\u53ef\u4ee5\u4e24\u5806\u4e2d\u5404\u62ff\u76f8\u7b49\u6570\u91cf\u7684\u77f3\u5934\u6216\u4ece\u4e00\u5806\u4e2d\u53d6\u8d70\u4efb\u610f<\/p>\n

          http:\/\/www.cnblogs.com\/flyinghearts\/archive\/2011\/03\/22\/1991972.html <\/p>\n

          \u6269\u5c55<\/p>\n

          1.A\u5148\u53d6\u59cb\u7ec8\u6784\u9020\u4e0d\u5b89\u5168\u5c40\u9762\u7ed9B,\u5373\u53ef\u786e\u4fdd\u5fc5\u80dc(\u524d\u63d0\u662f\u521d\u59cb\u72b6\u6001\u4e3a\u5b89\u5168)<\/p>\n

          2.NIM(4)<\/p>\n

          http:\/\/blog.sina.com.cn\/s\/blog_7689f89d01017u6y.html <\/p>\n

          http:\/\/episte.math.ntu.edu.tw\/articles\/mm\/mm_03_2_02\/index.html \/\/ by  zjerry \u53f0\u5927\u6570\u5b66\u7cfb\u7f51\u7ad9,\u5e0c\u671b\u4e24\u5cb8\u7edf\u4e00,\u7f51\u7ad9\u53ef\u4ee5\u6301\u4e45\u8bbf\u95ee<\/p>\n<\/div>\n

          <\/p>\n

          <\/p>\n","protected":false},"excerpt":{"rendered":"\u6269\u5927\u7f16\u7a0b_\u7f16\u7a0b\u5728\u751f\u6d3b\u4e2d\u7684\u5e94\u7528\u7684\u4f8b\u5b50\u7f16\u7a0b\u4e4b\u7f8e\u4e4b\u6269\u5c55\u95ee\u9898\u539f\u5e16\u5730\u5740\uff1ahttp:\/\/blog.csdn.net\/jerryzcx\/article\/details\/\u53c2\u8003\u94fe\u63a5:h...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/5556"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=5556"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/5556\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=5556"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=5556"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=5556"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}