zoukankan      html  css  js  c++  java
  • hdu 1576 A/B

    #include <stdio.h>
    #include <string.h>
    #include <iostream>
    #include <algorithm>
    #include <vector>
    #include <queue>
    #include <stack>
    #include <set>
    #include <map>
    #include <string>
    #include <math.h>
    #include <stdlib.h>
    #include <time.h>
    using namespace std;
    const int M=9973;
    typedef long long ll;
    
    void gcd(ll a, ll b, ll& d,ll& x, ll& y)
    {
        if(b==0)
        {
            d=a;
            x=1;
            y=0;
        }
        else
        {
            gcd(b,a%b,d,y,x);
            y-=(a/b)*x;
        }
    }
    int main()
    {
        int t;
        ll n,b,x,y,d,ans;
        scanf("%d",&t);
        while(t--)
        {
            cin>>n>>b;
            gcd(b,-M,d,x,y);
            x*=n/d;
            while(x<0) x+=M;
            cout<<x<<endl;
        }
        return 0;
    }

    版权声明:本文为博主原创文章,未经博主允许不得转载。http://xiang578.top/

  • 相关阅读:
    Python学习4
    Python学习3
    Python学习2
    表空间
    sqlplus常用设置
    HashMap和LinkedHashMap
    堆栈源码
    观察者模式
    策略模式
    java线性表
  • 原文地址:https://www.cnblogs.com/xryz/p/4847973.html
Copyright © 2011-2022 走看看