Pagini recente » Cod sursa (job #3292016) | Cod sursa (job #3293899) | Cod sursa (job #3290642) | Cod sursa (job #3292003)
#include <bits/stdc++.h>
#define int long long
using namespace std;
ifstream fin ("euclid3.in");
ofstream fout ("euclid3.out");
void Algoritmul_lui_Euclid_Extins(int a,int b,int &c,int &x,int &y){
if (b==0){
c = a;
x = 1;
y = 0;
}else{
int nx,ny;
Algoritmul_lui_Euclid_Extins(b,a%b,c,nx,ny);
x = ny;
y = nx-(a/b)*ny;
cout << x << ' ' << y << '\n';
}
return;
}
signed main()
{
int t;
fin >> t;
while (t--){
int a,b,c;
fin >> a >> b >> c;
int x,y,cc = c;
Algoritmul_lui_Euclid_Extins(a,b,cc,x,y);
cout << '\n';
if (a*x+b*y!=c) x = y = 0;
fout << x << ' ' << y << '\n';
}
return 0;
}