Time limit: 1000 ms
Memory limit: 32768kb
64bit Io format: % I64d & % i64
Description
(A/B) % 9973, but because a is very large, we only give n (n = A % 9973) (the given a must be divisible by B, and gcd (B, 9973) = 1 ).
Input
The first row of data is a T, indicating that there is a T group of data.
Each data set has two data sets: n (0 <= n <9973) and B (1 <= B <= 10 ^ 9 ).
Output
Corresponding to each group of data output (a/B) % 9973.
Sample Input
21000 5387 123456789
Sample output
79226060 is nothing to say .. Bx-9973y = N;
1 #include<cstdio> 2 3 int T,n,B,x,y; 4 5 int extend_eculid(int a,int b,int &x,int &y){ 6 if(!b){ 7 x=1;y=0; 8 return a; 9 }10 int d=extend_eculid(b,a%b,x,y);11 int t=x;x=y;y=t-a/b*x;12 return d;13 }14 15 int main(){16 scanf("%d",&T);17 while(T--){18 scanf("%d%d",&n,&B);19 int d=extend_eculid(B,9973,x,y);20 printf("%d\n",((x*n/d%9973)+9973)%9973);21 }22 }
Hdu1576 a/B, analog Element