Pagini recente » Cod sursa (job #2370978) | Cod sursa (job #3169129) | Cod sursa (job #1241137) | Cod sursa (job #1854212) | Cod sursa (job #2192094)
#include <bits/stdc++.h>
using namespace std;
int euclid(int a, int b, int& x, int& y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
int x0, y0, d;
d = euclid(b, a % b, x0, y0);
x = y0;
y = x0 - a / b * y0;
return d;
}
int main()
{
int t;
ifstream fin("euclid3.in");
fin >> t;
ofstream fout("euclid3.out");
for (int test = 0; test < t; ++test) {
int a, b, c, x, y, d;
fin >> a >> b >> c;
d = euclid(a, b, x, y);
if (c % d)
x = y = 0;
fout << x * (c / d) << " " << y * (c / d) << '\n';
}
fin.close();
fout.close();
return 0;
}