You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
895 B

2 years ago
// https://vjudge.csgrandeur.cn/problem/HDU-1576
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
/*
2
1000 53
87 123456789
7922
6060
1使+使LLint
*/
const int MOD = 9973;
LL qmi(LL a, LL k, LL p) {
LL res = 1;
while (k) {
if (k & 1) res = res * a % p; //如果res是int,可能会越界
k >>= 1;
a = a * a % p; //如果a是int, 可能会越界
}
return res;
}
int main() {
int T;
cin >> T;
while (T--) {
LL a, b;
cin >> a >> b;
LL x;
x = qmi(b, MOD - 2, MOD); // b理解为分母,同余MOD的逆元,变除法为乘法
LL res = a * x % MOD; // a* b在模MOD下的逆元 x
printf("%lld\n", res);
}
return 0;
}