{"rsdb":{"rid":"242207","subhead":"","postdate":"0","aid":"166753","fid":"49","uid":"1","topic":"1","content":"
\n

AC\u4ee3\u7801(C++<\/a>):<\/p> \n

\r\n#include \n  \n   \r\n#include \n   \n     #include \n    \n      #include \n     \n       #include \n      \n        #include\n        #include \n        \n          #include \n         \n           #include \n          \n            #include \n           \n             #define INF 0xfffffff #define MAXN 100105 using namespace std; long long A,B,C,k; void exgcd(long long a, long long b, long long &d, long long &x, long long &y) { if(!b){d=a; x=1; y=0;} else { exgcd(b, a%b, d, y, x); y-=x*(a\/b); } } int main(){ while(scanf("%lld%lld%lld%lld",&A,&B,&C,&k)){ if(A+B+C+k==0)break; long long a,b,c,d,x,y; a = C; b = (long long)1<\n            \n              \u603b\u7ed3: \u8bbe\u5faa\u73af\u4e86x\u6b21, A\u8d85\u8fc72^k(\u5373loop)\u4e86y\u6b21, \u5219\u53ef\u4ee5\u5f97\u5230\u8868\u8fbe\u5f0fCx-(2^k)y=B-A. \u8fd9\u662f\u4e00\u4e2a\u4e0d\u5b9a\u65b9\u7a0b, \u53ef\u80fd\u6709\u591a\u79cd\u89e3, \u800c\u6211\u4eec\u8981\u6c42\u7684\u662f\u4f7fx\u6700\u5c0f\u7684\u90a3\u4e2a\u89e3. \u6269\u5c55\u6b27\u51e0\u91cc\u5f97\u7b97\u6cd5\u5c31\u662f\u4e13\u95e8\u6c42\u5f62\u5982ax+by=c\u7684\u4e00\u4e2a\u7279\u6b8a\u7684\u89e3\u7684\u65b9\u6cd5, \u987a\u5e26\u6c42\u51faa\u548cb\u7684\u6700\u5927\u516c\u7ea6\u6570:\n             

 <\/p>\n

 <\/p>\n

\u5bf9\u5f62\u5982ax+by=c\u7684\u65b9\u7a0b, \u7528\u6269\u5c55\u6b27\u51e0\u91cc\u5f97\u7b97\u6cd5\u6c42\u51fax, y\u4ee5\u53caa, b\u7684\u6700\u5927\u516c\u7ea6\u6570d. \u5982\u679cc%d!=0\u5219\u65e0\u89e3, \u5982\u679c\u6709\u89e3, \u5219\u6c42x\u7684\u6700\u5c0f\u503cx0: \u8bbedm=b\/d, \u5219x0=((x*c\/d)%dm+dm)%dm.<\/p> \n <\/k;>\n <\/bitset>\n <\/string.h>\n <\/string>\n <\/math.h><\/map>\n <\/queue>\n <\/vector>\n <\/stdio.h>\n <\/algorithm>\n <\/iostream><\/pre> \n<\/div>","orderid":"0","title":"POJ 2115.C Looooops\u201c\u7f16\u7a0b\u5f00\u53d1\u201d","smalltitle":"","mid":"0","fname":"c++\u7f16\u7a0b\u57fa\u7840","special_id":"0","bak_id":"0","info":"0","hits":"233","pages":"1","comments":"0","posttime":"2017-12-11 09:18:48","list":"1512955128","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"https:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"POJ<\/A> 2115.C<\/A> Looooops<\/A> \u7f16\u7a0b<\/A> \u5f00\u53d1<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"113.110.148.226","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"POJ 2115.C Looooops\u201c\u7f16\u7a0b\u5f00\u53d1\u201d","lastview":"1711661266","digg_num":"7","digg_time":"1711000939","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}