标签:
http://acm.hdu.edu.cn/showproblem.php?pid=1576
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3351 Accepted Submission(s):
2545
#include<stdio.h> #include<string.h> #include<algorithm> #include<math.h> using namespace std; typedef long long ll; ll r; void gcd(ll a, ll b, ll &x, ll &y) { if(b == 0) { x = 1; y = 0; r = a; return ; } gcd(b, a % b, x, y); ll t; t = x; x = y; y = t - a / b * y; } int main() { int t; ll n, B, a, b, c, x, y; scanf("%d", &t); while(t--) { scanf("%lld %lld", &n, &B); a = B; b = 9973; c = n; gcd(a, b, x, y); ll s = b / r; x = c / r * x; x = (x % s + s) % s; printf("%lld\n", x); } return 0; }
标签:
原文地址:http://www.cnblogs.com/qq2424260747/p/4913824.html