Pagini recente » Cod sursa (job #700164) | Cod sursa (job #2313765) | Cod sursa (job #758687) | Cod sursa (job #1914682) | Cod sursa (job #2637410)
#include <iostream>
#include <fstream>
using namespace std;
void euclid(long long a, long long b, long long &d, long long &x, long long &y)
{
if (b == 0) {
d = a;
x = 1;
y = 0;
} else {
euclid(b, a % b, d, x, y);
long long newX = y;
long long newY = x - y * (a/b);
x = newX;
y = newY;
}
}
int main()
{
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int t;
fin >> t;
for (int test = 1; test <= t ; ++test) {
long long a, b, c, d, x, y;
fin >> a >> b >> c;
euclid(a, b, d, x, y);
if (c % d) {
fout << "0 " << "0 " << "\n";
} else {
fout << x * (c/d) << " " << y * (c/d) << "\n";
}
}
return 0;
}