其他分享
首页 > 其他分享> > Romantic HDU - 2669(扩欧)

Romantic HDU - 2669(扩欧)

作者:互联网

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
void gcd(LL a, LL b, LL &d, LL &x, LL &y)
{
    if(!b)
    {
        d = a;
        x = 1;
        y = 0;
    }
    else
    {
        gcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}
int main()
{
    std::ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    LL a, b;
    LL x, y;
    while(cin >> a >> b)
    {
        LL x, y, d;
        gcd(a, b, d, x, y);
        if(d != 1)
            cout << "sorry" << endl;
        else
        {
            while(x < 0)
            {
                x += b;
                y -= a;
            }
            cout << x << " " << y << endl;
        }


    }
}

标签:std,HDU,gcd,LL,long,freopen,txt,扩欧,Romantic
来源: https://www.cnblogs.com/KeepZ/p/11342116.html