Pagini recente » Cod sursa (job #2361285) | Cod sursa (job #2842844) | Cod sursa (job #91056) | Mihnea Andreescu | Cod sursa (job #2553525)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int N;
void Euclid(int a, int b, int &d, int &x, int &y){
if(b==0){
d=a, x=1, y=0;
return;
}
int x0, y0;
Euclid(b,a%b,d, x0,y0);
x=y0;
y=x0-(a/b)*y0;
}
int main(){
fin>>N;
for(int i=1;i<=N;++i)
{
int a,b, d, x,y;
fin>>a>>b>>d;
Euclid(a,b,d, x,y);
fout<<x<<" "<<y<<"\n";
}
}