标签:
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4252 Accepted Submission(s): 3277
#include <iostream> using namespace std; typedef long long ll; ll extgcd(ll a,ll b,ll &x,ll &y) { int d=a; if(b!=0) { d=extgcd(b,a%b,y,x); y-=(a/b*x); } else { x=1;y=0; } return d; } int main() { int T; cin>>T; while(T--) { ll a,b,c; cin>>c>>a; b=9973; ll x=0,y=0; extgcd(a,b,x,y); x%=b; while(x<0)x+=b; x=(x*c)%b; cout<<x<<endl; } return 0; }
标签:
原文地址:http://www.cnblogs.com/program-ccc/p/5701566.html