Pagini recente » Cod sursa (job #262244) | Cod sursa (job #1263107) | Cod sursa (job #2163525) | Cod sursa (job #2242994) | Cod sursa (job #1484246)
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#define INF ( (1 << 30) - 1 + (1 << 30) )
#define mod 666013
using namespace std;
int t, x, y, a, b, c, d;
int gcd(int a, int b, int &x, int &y)
{
if(b == 0)
{
x = 1;
y = 0;
return a;
}
int x0, y0, d;
d = gcd(b, a % b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
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);
x = y = 0;
d = gcd(a, b, x, y);
if(c % d)
printf("0 0\n");
else
printf("%d %d\n", x * (c / d), y * (c / d));
}
return 0;
}