首页 > 其他 > 详细

A/B

时间:2017-04-21 23:51:32      阅读:218      评论:0      收藏:0      [点我收藏+]
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
using namespace std;
int extend_gcd(int a, int b, int &x, int &y) {
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    int t = extend_gcd(b, a % b, y, x);
    y -= a / b * x;
    return t;
}
int main() {
    int T, n, b, x, y;
    cin >> T;
    while (T--) {
        cin >> n >> b;
        extend_gcd(9973, b, x, y);
        y *= n;
        y = (9973 + y % 9973) % 9973;
        cout << y << endl;
    }
}

 

A/B

原文:http://www.cnblogs.com/NWUACM/p/6746522.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!