{"id":12,"date":"2009-11-01T16:09:00","date_gmt":"2009-11-01T08:09:00","guid":{"rendered":"http:\/\/localhost\/?p=12"},"modified":"2009-11-01T16:09:00","modified_gmt":"2009-11-01T08:09:00","slug":"sgu_140","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/wjmzbmr\/?p=12","title":{"rendered":"sgu 140"},"content":{"rendered":"<p> \u6709\u70b9\u5c0f\u96be\u7684\u6570\u8bba\u95ee\u9898\u54e6\u3002\u3002<br \/>aX\uff1db\uff08mod n\uff09\u5f88\u597d\u6c42\u5427\u3002\u3002<br \/>\u600e\u4e48\u624d\u80fd\u628a\u8fd9\u4e2a\u95ee\u9898\u5316\u6210\u8fd9\u79cd\u5462\uff1f<br \/>\u9996\u5148\u5e8f\u5217A\u53ef\u4ee5mod P\u3002\u3002<br \/>\u56e0\u4e3aa\u548cb\u53ef\u4ee5\u7ec4\u6210gcd\uff08a\uff0cb\uff09\u7684\u4efb\u4f55\u500d\u6570\u3002\u3002\u53cd\u4e4b\u4e5f\u662f\u3002\u3002<br \/>\u56e0\u4e3a\u53ef\u4ee5\u7528\u6269\u5c55\u6b27\u51e0\u91cc\u5f97\u7b97\u51faax+by=gcd(a,b)\u561b\u3002\u3002<br \/>\u6545\u53ef\u4ee5\u628aa\u548cb\u6362\u6210gcd\uff08a\uff0cb\uff09\u3002\u3002\u3002<br \/>\u7136\u540e\u5c31\u4e00\u4e2a\u4e2a\u5904\u7406\u3002\u3002<br \/>\u82e5k\u662f\u4e4b\u524d\u7684\u6240\u6709\u6570\u7684gcd\u3002\u3002\u5f53\u524d\u5904\u7406t\u3002\u3002<br \/>\u5f97\u51fakx+ty=gcd(k,t)\u3002\u3002<br \/>\u90a3\u4e48\u4e4b\u524d\u6240\u6709\u6570\u7684\u7cfb\u6570\u5168\u90e8*x\uff08\u7136\u540e\u518dmodP\uff09\u3002\u3002t\u7684\u7cfb\u6570\u5c31\u662fy<br \/>\u5c31\u53ef\u4ee5\u4f7f\u7cfb\u6570\u6ca1\u6709\u95ee\u9898\u4e86\u3002\u3002<br \/>\u65e0\u89e3\u5c31\u662fgcd\uff08all\u5305\u62ecn\uff09\u65e0\u6cd5\u6574\u9664b\u3002\u3002<br \/>\u7136\u540e\u76f4\u63a5\u8f93\u51fa\u7cfb\u6570\u5c31\u53ef\u4ee5\u4e86\u3002\u3002<br \/>P.S\u4e3a\u4e86\u65b9\u4fbf\u53ef\u4ee5\u628aP\u4e5f\u5e26\u5165\u65b9\u7a0b\u5199\u6210&#8230;..+PXn+1=b..<br \/>Code\u3002\u3002\u3002<br \/>#include&lt;stdio.h&gt;<br \/>#include&lt;iostream&gt;<br \/>using namespace std;<br \/>const int maxn=200;<br \/>long long N,P,B;<br \/>long long A[maxn];<br \/>long long X[maxn];<br \/>long long gcd(long long a,long long b)<br \/>{<br \/>while(b){int t=a;a=b;b=t%b;}<br \/>return a;<br \/>}<br \/>void get(long long a,long long b,long long&amp;x,long long&amp;y)<br \/>{<br \/>if(b==0)<br \/>{<br \/>x=1;y=0;<br \/>return;<br \/>}<br \/>get(b,a%b,y,x);<br \/>y-=(a\/b)*x;<br \/>}<br \/>int main()<br \/>{<br \/>cin&gt;&gt;N&gt;&gt;P&gt;&gt;B;<br \/>cin&gt;&gt;A[0];long long k=A[0];<br \/>for(int i=1;i&lt;N;i++)<br \/>{<br \/>cin&gt;&gt;A[i];&#160;&#160;&#160; <br \/>A[i]%=P;<br \/>k=gcd(k,A[i]);<br \/>}<br \/>A[N]=P;<br \/>k=gcd(k,A[N]);<br \/>if(B%k!=0)<br \/>{<br \/>cout&lt;&lt;&quot;NO&quot;&lt;&lt;endl;<br \/>return 0;<br \/>}&#160;&#160;&#160; <br \/>k=gcd(A[0],A[1]);<br \/>get(A[0],A[1],X[0],X[1]);<br \/>for(int i=2;i&lt;=N;i++)<br \/>{<br \/>long long x;<br \/>get(k,A[i],x,X[i]);<br \/>for(int j=0;j&lt;i;j++)<br \/>{<br \/>X[j]*=x;<br \/>X[j]%=P;<br \/>while(X[j]&lt;0)<br \/>X[j]+=P;<br \/>}<br \/>k=gcd(k,A[i]);<br \/>}<br \/>cout&lt;&lt;&quot;YES&quot;&lt;&lt;endl;<br \/>for(int i=0;i&lt;N;i++)<br \/>{<br \/>X[i]*=(B\/k);<br \/>X[i]%=P;<br \/>while(X[i]&lt;0) X[i]+=P;<br \/>cout&lt;&lt;X[i]&lt;&lt;&quot; &quot;;<br \/>}<br \/>} <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u70b9\u5c0f\u96be\u7684\u6570\u8bba\u95ee\u9898\u54e6\u3002\u3002aX\uff1db\uff08mod n\uff09\u5f88\u597d\u6c42\u5427\u3002\u3002\u600e\u4e48\u624d\u80fd\u628a\u8fd9\u4e2a\u95ee\u9898\u5316\u6210\u8fd9\u79cd\u5462\uff1f\u9996\u5148\u5e8f\u5217A\u53ef\u4ee5mod P\u3002\u3002\u56e0\u4e3aa\u548cb\u53ef\u4ee5\u7ec4\u6210gcd\uff08a\uff0cb\uff09\u7684\u4efb\u4f55\u500d\u6570\u3002\u3002\u53cd\u4e4b\u4e5f\u662f\u3002\u3002\u56e0\u4e3a\u53ef\u4ee5\u7528\u6269\u5c55\u6b27\u51e0\u91cc\u5f97\u7b97\u51faax+by=gcd(a,b)\u561b\u3002\u3002\u6545\u53ef\u4ee5\u628aa\u548cb\u6362\u6210gcd\uff08a\uff0cb\uff09\u3002\u3002\u3002\u7136\u540e\u5c31\u4e00\u4e2a\u4e2a\u5904\u7406\u3002\u3002\u82e5k\u662f\u4e4b\u524d\u7684\u6240\u6709\u6570\u7684gcd\u3002\u3002\u5f53\u524d\u5904\u7406t\u3002\u3002\u5f97\u51fakx+ty=gcd(k,t)\u3002\u3002\u90a3\u4e48\u4e4b\u524d\u6240\u6709\u6570\u7684\u7cfb\u6570\u5168\u90e8*x\uff08\u7136\u540e\u518dmodP\uff09\u3002\u3002t\u7684\u7cfb\u6570\u5c31\u662fy\u5c31\u53ef\u4ee5\u4f7f\u7cfb\u6570\u6ca1\u6709\u95ee\u9898\u4e86\u3002\u3002\u65e0\u89e3\u5c31\u662fgcd\uff08all\u5305\u62ecn\uff09\u65e0\u6cd5\u6574\u9664b\u3002\u3002\u7136\u540e\u76f4\u63a5\u8f93\u51fa\u7cfb\u6570\u5c31\u53ef\u4ee5\u4e86\u3002\u3002P.S\u4e3a\u4e86\u65b9\u4fbf\u53ef\u4ee5\u628aP\u4e5f\u5e26\u5165\u65b9\u7a0b\u5199\u6210&#8230;..+PXn+1=b..Code\u3002\u3002\u3002#include&lt;stdio.h&gt;#include&lt;iostream&gt;using namespace std;const int maxn=200;long long N,P,B;long long A[maxn];long long X[maxn];long long gcd(long long a,long long b){while(b){int t=a;a=b;b=t%b;}return a;}void get(long long a,long long b,long long&amp;x,long long&amp;y){if(b==0){x=1;y=0;return;}get(b,a%b,y,x);y-=(a\/b)*x;}int main(){cin&gt;&gt;N&gt;&gt;P&gt;&gt;B;cin&gt;&gt;A[0];long long k=A[0];for(int i=1;i&lt;N;i++){cin&gt;&gt;A[i];&#160;&#160;&#160; A[i]%=P;k=gcd(k,A[i]);}A[N]=P;k=gcd(k,A[N]);if(B%k!=0){cout&lt;&lt;&quot;NO&quot;&lt;&lt;endl;return 0;}&#160;&#160;&#160; k=gcd(A[0],A[1]);get(A[0],A[1],X[0],X[1]);for(int i=2;i&lt;=N;i++){long long x;get(k,A[i],x,X[i]);for(int j=0;j&lt;i;j++){X[j]*=x;X[j]%=P;while(X[j]&lt;0)X[j]+=P;}k=gcd(k,A[i]);}cout&lt;&lt;&quot;YES&quot;&lt;&lt;endl;for(int i=0;i&lt;N;i++){X[i]*=(B\/k);X[i]%=P;while(X[i]&lt;0) X[i]+=P;cout&lt;&lt;X[i]&lt;&lt;&quot; &quot;;}}<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/12"}],"collection":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/12\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}