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;
        }


    }
}
上一篇:关于cas server无法通过session持久化方式实现集群的问题


下一篇:自然语言处理-应用场景-聊天机器人(四):代码封装、对外提供接口