Pagini recente » Cod sursa (job #615) | Cod sursa (job #84658) | Cod sursa (job #3252254) | Cod sursa (job #537891) | Cod sursa (job #2710737)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int main() {
int t; fin >> t;
while (t--) {
int a, b, c; fin >> a >> b >> c;
int xa = 1, ya = 0, xb = 0, yb = 1;
while (b) {
int q = a / b;
int r = a % b;
a = b;
b = r;
int xr = xa - q * xb;
int yr = ya - q * yb;
xa = xb; ya = yb;
xb = xr; yb = yr;
}
if (c % a)
fout << "0 0\n";
else
fout << c / a * xa << ' ' << c / a * ya << '\n';
}
return 0;
}