{"id":684,"date":"2019-03-04T16:52:47","date_gmt":"2019-03-04T08:52:47","guid":{"rendered":"http:\/\/SmokeyDays.top\/wordpress\/?p=684"},"modified":"2019-03-04T16:54:12","modified_gmt":"2019-03-04T08:54:12","slug":"lp4777-%e3%80%90%e6%a8%a1%e6%9d%bf%e3%80%91%e6%89%a9%e5%b1%95%e4%b8%ad%e5%9b%bd%e5%89%a9%e4%bd%99%e5%ae%9a%e7%90%86%ef%bc%88excrt%ef%bc%89","status":"publish","type":"post","link":"http:\/\/SmokeyDays.top\/wordpress\/2019\/03\/04\/lp4777-%e3%80%90%e6%a8%a1%e6%9d%bf%e3%80%91%e6%89%a9%e5%b1%95%e4%b8%ad%e5%9b%bd%e5%89%a9%e4%bd%99%e5%ae%9a%e7%90%86%ef%bc%88excrt%ef%bc%89\/","title":{"rendered":"lp4777 \u3010\u6a21\u677f\u3011\u6269\u5c55\u4e2d\u56fd\u5269\u4f59\u5b9a\u7406\uff08EXCRT\uff09"},"content":{"rendered":"\n<p>$$ \\left\\{ \\begin{matrix}x\\equiv a_{1} \\pmod{p_1} \\\\x\\equiv a_{2}\\pmod{p_2}\\\\\\cdots\\\\x\\equiv a_{n}\\pmod{p_i}\\end{matrix} \\right.$$<br>\n\u5bf9\u4e8e\u8fd9\u4e2a\u65b9\u7a0b\uff0c\u5f53\u6240\u6709\u6a21\u6570\u4e24\u4e24\u4e92\u8d28\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e2d\u56fd\u5269\u4f59\u5b9a\u7406\u6765\u6c42\u89e3\u3002<br>\n\u7136\u800c\uff0c\u5018\u82e5\u5e76\u4e0d\u6ee1\u8db3\u8fd9\u4e2a\u6761\u4ef6\uff0c\u666e\u901a\u7684\u4e2d\u56fd\u5269\u4f59\u5b9a\u7406\u5c31\u672a\u5fc5\u80fd\u591f\u594f\u6548\u4e86\u3002<br>\n\u6211\u4eec\u5c1d\u8bd5\u5c06\u4e2d\u56fd\u5269\u4f59\u5b9a\u7406\u7684\u6210\u7acb\u6761\u4ef6\u8fdb\u884c\u63a8\u5e7f\uff0c\u4ece\u800c\u5f97\u5230\u4e00\u79cd\u88ab\u79f0\u4e3a\u300c\u6269\u5c55\u4e2d\u56fd\u5269\u4f59\u5b9a\u7406\u300d\u7684\u7b97\u6cd5\uff0c\u4ee5\u89e3\u51b3\u6a21\u6570\u5e76\u4e0d\u4fdd\u8bc1\u4e92\u8d28\u7684\u60c5\u51b5\u4e0b\u7684\u7ebf\u6027\u540c\u4f59\u65b9\u7a0b\u7ec4\u6c42\u89e3\u3002<br>\n\u5bf9\u4e8e\u6bcf\u4e2a\u65b9\u7a0b\u7684\u89e3\uff0c\u5b83\u6784\u6210\u4e86\u4e00\u4e2a\u89e3\u96c6\u3002\u800c\u6211\u4eec\u9700\u8981\u627e\u5230\u7684\u662f\u8fd9\u4e2a\u89e3\u96c6\u4e2d\u6700\u5c0f\u7684\u4e14\u6ee1\u8db3\u4e0b\u4e00\u4e2a\u65b9\u7a0b\u7684\u6b63\u6574\u6570\u89e3\u3002<br>\n\u5bb9\u6613\u8bc1\u660e\uff0c\u4e00\u4e9b\u7ebf\u6027\u540c\u4f59\u65b9\u7a0b\u7ec4\u7684\u89e3\u96c6\u4e00\u5b9a\u662f\u5173\u4e8e\u6240\u6709\u6a21\u6570\u7684\u6700\u5c0f\u516c\u7ea6\u6570\u540c\u4f59\u7684\u4e00\u4e2a\u6570\u3002<br>\n\u4e8e\u662f\uff0c\u6211\u4eec\u4ee4\\(x_k\\)\u4e3a\u65b9\u7a0b\\(1\\to k\\)\u7684\u6700\u5c0f\u6b63\u6574\u6570\u89e3\uff1a<br>\n$$\\begin{equation}\\begin{split}P,st:P&amp;=&amp;lcm({p_{i},i\\in [1,k]})\\\\x_{k+1}&amp;=&amp;x_{k}+tP\\\\x_{k+1}&amp;\\equiv&amp;a_{k+1}&amp;\\pmod{p_{k+1}}\\\\x_{k}+tP&amp;\\equiv&amp;a_{k+1}&amp;\\pmod{p_{k+1}}\\\\tP&amp;\\equiv&amp;a_{k+1}-x_{k}&amp;\\pmod{p_{k+1}}\\end{split}\\end{equation}$$<br>\n\u6700\u540e\u7684\u90a3\u4e2a\u5f0f\u5b50\u53ef\u4ee5\u8f6c\u5316\u5f62\u5f0f\u7136\u540e\u4e0a\u6269\u6b27\u3002<br>\n\u8fd9\u5c31\u5b8c\u6210\u4e86\u4e00\u79cd\u9012\u63a8\u6c42\u89e3\u4e0d\u4fdd\u8bc1\u6a21\u6570\u4e92\u8d28\u7684\u7ebf\u6027\u540c\u4f59\u65b9\u7a0b\u7ec4\u7684\u65b9\u6848\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream>\n#include&lt;cstdio>\n\nlong long MOD=1;\n\n\ninline long long mlt(long long A,long long X,long long P){\n\tlong long BS=A,RT=0;\n\twhile(X){\n\t\tif(X&amp;1){\n\t\t\tRT+=BS;\n\t\t\tRT%=P;\n\t\t}\n\t\tBS+=BS;\n\t\tBS%=P;\n\t\tX>>=1;\n\t}\n\treturn RT;\n}\ninline long long gcd(long long A,long long B){\n\treturn B?gcd(B,A%B):A;\n}\ninline long long exgcd(long long A,long long B,long long &amp;X,long long &amp;Y,long long D=0){\n\treturn B?(D=exgcd(B,A%B,Y,X),Y-=A\/B*X,D):(X=1,Y=0,A);\n}\nlong long n,a[100005],b[100005];\nvoid init(){\n\tscanf(\"%lld\",&amp;n);\n\tfor(int i=1;i&lt;=n;++i){\n\t\tscanf(\"%lld%lld\",&amp;b[i],&amp;a[i]);\n\t}\n\tlong long X,Y,T,C,ans=a[1];\n\tMOD=b[1];\n\tfor(int i=2;i&lt;=n;++i){\n\t\tC=(a[i]-ans%b[i]+b[i])%b[i];\n\t\tX=exgcd(MOD,b[i],T,Y);\n\t\tif(C%X!=0){\n\t\t\tputs(\"F**KING HARD!\");\n\t\t\treturn;\n\t\t}\n\t\tT=mlt(T,C\/X,b[i]\/X);\n\t\tans+=T*MOD;\n\t\tMOD\/=X;\n\t\tMOD*=b[i];\n\t\tans=(ans%MOD+MOD)%MOD;\n\t\t\n\t}\n\tprintf(\"%lld\\n\",(ans+MOD)%MOD);\n}\n\nint main(){\n\tinit();\n\treturn 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>$$ \\left\\{ \\begin{matrix}x\\equiv a_{1} \\pmod{p_1} \\\\x\\e &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/SmokeyDays.top\/wordpress\/2019\/03\/04\/lp4777-%e3%80%90%e6%a8%a1%e6%9d%bf%e3%80%91%e6%89%a9%e5%b1%95%e4%b8%ad%e5%9b%bd%e5%89%a9%e4%bd%99%e5%ae%9a%e7%90%86%ef%bc%88excrt%ef%bc%89\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201clp4777 \u3010\u6a21\u677f\u3011\u6269\u5c55\u4e2d\u56fd\u5269\u4f59\u5b9a\u7406\uff08EXCRT\uff09\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":[96,97,24,27,8,6,5],"tags":[],"_links":{"self":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/684"}],"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=684"}],"version-history":[{"count":2,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/684\/revisions"}],"predecessor-version":[{"id":687,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/684\/revisions\/687"}],"wp:attachment":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/media?parent=684"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/categories?post=684"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/tags?post=684"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}