Pagini recente » Cod sursa (job #2288403) | Cod sursa (job #1721594) | Cod sursa (job #458010) | Cod sursa (job #1491836) | Cod sursa (job #2674635)
#include <cstdio>
#include <iostream>
using namespace std;
void euclid_extins(long long a, long long b, long long &d, long long &x, long long &y) {
if (!b) {
x = 1;
y = 0;
d = a;
return;
}
long long x1, y1;
euclid_extins(b, a % b, d, x1, y1);
x = y1;
y = x1 - (a / b) * y1;
}
int main() {
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
long long n, a, b, c;
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
scanf("%lld%lld%lld", &a, &b, &c);
long long d, x, y;
euclid_extins(a, b, d, x, y);
if (c % d)
printf("0 0\n");
else
printf("%lld %lld\n", x * c / d, y * c / d);
}
return 0;
}