标签:des style blog io color os java sp strong
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2390 Accepted Submission(s): 1731
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long qword; qword ext_gcd(qword a,qword b,qword &x,qword &y) { if (a%b==0) { //a*x+b*y==b x=0;y=1; return y; } qword ret=ext_gcd(b,a%b,x,y); qword tx=x,ty=y; x=ty; y=tx-a/b*ty; return ret; } int main() { //freopen("input.txt","r",stdin); //A=9973*x+n //(9973*x+n)=y*B //9973*x-B*y==-n qword n,a,b,x,y,yy,xx; int nn; scanf("%d",&nn); qword g; while (nn--) { scanf("%I64d%I64d",&n,&b); g=ext_gcd(9973,b,x,y); x*=-n;y*=n; // cout<<9973*x-b*y<<endl; yy=(y%9973+9973)%9973; xx=x-(y-yy)/9973*b; // cout<<9973*xx-b*yy<<endl; cout<<yy<<endl; } }
标签:des style blog io color os java sp strong
原文地址:http://www.cnblogs.com/mhy12345/p/4057678.html