Pagini recente » Cod sursa (job #561050) | Cod sursa (job #3230166) | Cod sursa (job #1569270) | Cod sursa (job #2070719) | Cod sursa (job #589844)
Cod sursa(job #589844)
#include <cstdlib>
#include <iostream>
#include <string>
#include <cstdio>
#include <hash_set>
#include <algorithm>
#include <regex>
using namespace std;
int T, a, b, c, d, x, y;
int gcd(int a, int b, int& x, int& y) {
if (!b) {
x = 1;
y = 0;
return a;
}
int xx, yy;
int d = gcd(b, a % b, xx, yy);
x = yy;
y = xx - (a / b) * yy;
return d;
}
int main() {
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
scanf("%d", &T);
while (T--) {
scanf("%d %d %d", &a, &b, &c);
d = gcd(a, b, x, y);
if (c % d) {
puts("0 0");
} else {
printf("%d %d\n", x * (c / d), y * (c / d));
}
}
fclose(stdout);
fclose(stdin);
return 0;
}