Pagini recente » Cod sursa (job #1759452) | Cod sursa (job #801696) | Cod sursa (job #2304473) | Cod sursa (job #1910391) | Cod sursa (job #2503915)
#include <bits/stdc++.h>
using namespace std;
int gcdExtended(int a, int b, int &x, int &y) {
if (a == 0) {
x = 0;
y = 1;
return b;
}
int x1, y1;
int gcd = gcdExtended(b % a, a, x1, y1);
x = y1 - (b / a) * x1;
y = x1;
return gcd;
}
int main() {
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int x,y,a,b,c,n,nr;
fin >> n;
for (int i = 0;i < n;i++) {
fin >> a >> b >> c;
nr = gcdExtended(a, b, x, y);
if (c % nr)
fout << "0 0" << '\n';
else
fout << x * (c / nr) << " " << y * (c / nr) << '\n';
}
return 0;
}