Cod sursa(job #3322462)

Utilizator horatiu.avramAvram Popa Cristian Horatiu horatiu.avram Data 14 noiembrie 2025 10:58:30
Problema Algoritmul lui Euclid extins Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.55 kb
#include <bits/stdc++.h>

using namespace std;

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

typedef long long ll;

void euclid(ll a,ll b,ll *d,ll *x,ll *y) {
    if(b==0) {
        *d=a;
        *x=1;
        *y=0;
    } else {
        ll x0,y0;
        euclid(b,a%b,d,&x0,&y0);
        *x=y0;
        *y=x0-(a/b)*y0;
    }
}

signed main() {
    ll t;
    fin>>t;
    while(t--) {
        ll a,b,c,x,y;
        fin>>a>>b>>c;
        euclid(a,b,&c,&x,&y);
        fout<<x<<' '<<y<<'\n';
    }
    return 0;
}