Pagini recente » Cod sursa (job #2370871) | Cod sursa (job #2625567) | Cod sursa (job #172937) | Cod sursa (job #561368) | Cod sursa (job #2493183)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
void euclid(long long a, long long b, long long &d, long long &x, long long &y) {
if (b == 0) {
x = 1;
y = 0;
d = a;
}
else {
long long w, z;
euclid(b, a%b, d, w, z);
x = z;
y = w - (a / b) * z;
}
}
int main()
{
int T, i;
fin >> T;
long long a, b, c, d;
long long x = 0, y = 0;
for (i = 0; i < T; i++) {
fin >> a >> b >> c;
euclid(a, b, d, x, y);
if (c % d == 0) fout << x * c / d << ' ' << y * c / d << '\n';
else fout << 0 << ' ' << 0 << '\n';
}
}