Pagini recente » Cod sursa (job #3316964) | Cod sursa (job #3350592) | Cod sursa (job #3349158) | Cod sursa (job #3302264) | Cod sursa (job #3353031)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
void euclid(int a, int b, int &d, int &x, int &y){
if(b == 0){
d = a;
x = 1;
y = 0;
}
else{
int x0,y0;
euclid(b, a%b, d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main()
{
int n;
fin >> n;
while(n--){
int a, b, c;
fin >> a >> b >> c;
int d, x, y;
euclid(a, b, d, x, y);
fout << x << " " << y << '\n';
}
return 0;
}