Pagini recente » Cod sursa (job #378148) | Cod sursa (job #1784759) | Profil Yahia_Emara | Cod sursa (job #237189) | Cod sursa (job #1404522)
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#ifdef HOME
const string inputFile = "input.txt";
const string outputFile = "output.txt";
#else
const string problemName = "euclid3";
const string inputFile = problemName + ".in";
const string outputFile = problemName + ".out";
#endif
typedef long long int lld;
int N;
int gcd(int a, int b, lld &x, lld &y) {
if(!b) {
x = 1;
y = 0;
return a;
}
lld x0, y0;
int d;
d = gcd(b, a % b, x0, y0);
x = y0;
y = x0 - y0 * (a / b);
return d;
}
int main() {
int a, b, c, d;
lld x, y;
#ifndef ONLINE_JUDGE
freopen(inputFile.c_str(), "r", stdin);
freopen(outputFile.c_str(), "w", stdout);
#endif
scanf("%d", &N);
while(N--) {
scanf("%d%d%d", &a, &b, &c);
d = gcd(a, b, x, y);
if(c % d) x = y = 0;
else x *= (c / d), y *= (c / d);
printf("%lld %lld\n", x, y);
}
return 0;
}