Pagini recente » Cod sursa (job #2419494) | Cod sursa (job #3264939) | Cod sursa (job #553994) | Cod sursa (job #2107689) | Cod sursa (job #2974459)
/// [A][M][C][B][N] ///
#include <bits/stdc++.h>
const int mod = 20173333;
const int inf = 0x3f3f3f3f;
const char sp = ' ', nl = '\n';
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int gcdExtended(int a, int b, int& x, int& y)
{
if (a == 0)
{
x = 0;
y = 1;
return b;
}
int x1, y1;
int gcd = gcdExtended(b % a, a, x1, y1);
x = y1 - (b / a) * x1;
y = x1;
return gcd;
}
int main() {
int t;
fin >> t;
while (t--) {
int a, b, x, y, c;
cin >> a >> b >> c;
int g = gcdExtended(a, b, x, y);
if (c % g) {
fout << 0 << sp << 0 << nl;
}
else {
fout << x * (c / g) << sp << y * (c / g) << nl;
}
}
}