要求(A/B)%9973,但由于A很大,我們只給出n(n=A%9973)(我們給定的A必能被B整除,且gcd(B,9973) = 1)。
Input
數(shù)據(jù)的第一行是一個T,表示有T組數(shù)據(jù)。
每組數(shù)據(jù)有兩個數(shù)n(0 <= n < 9973)和B(1 <= B <= 10^9)。
Output
對應每組數(shù)據(jù)輸出(A/B)%9973。
Sample Input
2
1000 53
87 123456789
Sample Output
7922
6060
此題需要考慮到輸入數(shù)值的問題,保證值不能過大,會發(fā)生溢出,所以在此采用一個循環(huán)判斷,找到A的值即可。
#include<iostream>
using namespace std;
int main()
{
int T;
cin >> T;
int i = 0;
while (i < T)
{
long long x, y,o;
cin >> x >> y;
for (o = 0;o < 9973; o++)
{
if ((o*y - x) % 9973 == 0)
{
break;
}
}
cout << o << endl;
i++;
}
return 0;
}