Pagini recente » Cod sursa (job #2791751) | Cod sursa (job #852509) | Cod sursa (job #1804615) | Cod sursa (job #1606715) | Cod sursa (job #2646426)
#include <bits/stdc++.h>
using namespace std;
const int DIM = (1 << 10) + 5;
int a[DIM], b[DIM], dp[DIM][DIM], ans[DIM];
int ext_euclid(int a, int b, int & x, int & y)
{
if(b == 0) {
x = 1;
y = 0;
return a;
}
int x1, y1;
int d = ext_euclid(b, a % b, x1, y1);
x = y1;
y = x1 - y1 * (a / b);
return d;
}
int main()
{
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
int test;
scanf("%d", &test);
for(; test; --test) {
int a, b, c, x = 0, y = 0;
scanf("%d%d%d", &a, &b, &c);
int sol = ext_euclid(a, b, x, y);
if(c % sol == 0) {
printf("%d %d\n", x * (c / sol), y * (c / sol));
}
else printf("0 0\n");
}
return 0;
}