Pagini recente » Cod sursa (job #1579606) | Cod sursa (job #63662) | Cod sursa (job #2795373) | Cod sursa (job #617738) | Cod sursa (job #2460815)
#include <bits/stdc++.h>
#define l long long
using namespace std;
void euclid(l a, l b, l& d, l& x, l&y) {
if(b == 0) { d = a; x = 1; y = 0; return; }
l x0, y0; euclid(b, a % b, d, x, y);
x0 = y; y0 = x - (a / b) * y; x = x0; y = y0;
}
int main() {
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
l t, a, b, c, x, y, d; fin >> t;
do {
fin >> a >> b >> c; euclid(a, b, d, x, y);
if(c % d)
fout << "0 0\n";
else
((fout << x * c / d).put(' ') << y * c / d).put('\n');
} while(--t);
}