Pagini recente » Cod sursa (job #2381238) | Cod sursa (job #194431) | Cod sursa (job #2534104) | Cod sursa (job #2875047) | Cod sursa (job #2615162)
#include <bits/stdc++.h>
#define DAU ios_base::sync_with_stdio(false); fin.tie(0); fout.tie(0);
#define PLEC fin.close(); fout.close(); return 0;
using namespace std;
const string problem("euclid3");
ifstream fin(problem + ".in");
ofstream fout(problem + ".out");
inline int Euclid(int a, int b, int& x, int& y) {
if (!b) {
x = 1, y = 0;
return a;
}
int x0, y0, d = Euclid(b, a % b, x0, y0);
x = y0, y = x0 - (a / b) * y0;
return d;
}
int t, a, b, c, d, x, y;
int main() {
DAU
fin >> t;
while (t--) {
fin >> a >> b >> c;
d = Euclid(a, b, x, y);
if (c % d == 0)
fout << x * (c / d) << ' ' << y * (c / d) << '\n';
else fout << "0 0\n";
}
PLEC
}