Cod sursa(job #2848046)

Utilizator armand09Armand Miron armand09 Data 12 februarie 2022 09:28:32
Problema Algoritmul lui Euclid extins Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.01 kb
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define int long long

using namespace std;
#define pb push_back
#define FASTIO ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)

ifstream fin("euclid3.in");
ofstream fout("euclid3.out");

#define pii pair<int , int>
#define sz(a) ((int)((a).size()))
const unsigned int MAX = 1e2+1;
inline int euclid(int a, int b , int &d , int &x ,int &y)
{
    if(b==0)
    {
        x=1  , y = 0;
        return a;
    }
    int x0 , y0;
    d = euclid(b , a%b ,d, x0 , y0);
    x=y0;
    y = x0 - (a/b) * y0;
    return d;
}
int T;
int32_t main()
{
    FASTIO;
    fin>>T;
    while(T--)
    {
        int a, b , c;
        int x1 , x2 , d;
        cin>>a>>b>>c;
        euclid(a,b,d,x1,x2);
        if(x1>2000000000||x1<-2000000000 || x2>2000000000||x2<-2000000000)
            fout<<0<<' '<<0<<'\n';
        else
            c % d ? fout<<0<<' '<<0<<'\n' : fout<<x1*(c/d)<<' '<<x2*(c/d)<<'\n';
    }
}