Pagini recente » Cod sursa (job #2725097) | Cod sursa (job #1814012) | Cod sursa (job #2763759) | Cod sursa (job #3143924) | Cod sursa (job #1182347)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
void euclid(int a, int b, int&x, int&y, int&d) {
if (b == 0) {
x = 1;
y = 0;
d = a;
} else {
int x0, y0;
euclid(b, a%b, x0, y0, d);
x = y0;
y = x0 - (a/b) * y0;
}
}
int main() {
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
int a, b, c, x, y, d, t;
cin >> t;
while (t--) {
cin >> a >> b >> c;
euclid(a, b, x, y, d);
if (c % d == 0) {
cout << x*(c/d) << " " << y*(c/d) << endl;
} else {
cout << 0 << " " << 0 << endl;
}
}
return 0;
}