Pagini recente » Cod sursa (job #261406) | Cod sursa (job #459379) | Borderou de evaluare (job #2080212) | Cod sursa (job #2774121) | Cod sursa (job #2576333)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
void euclid(int a, int b, int &x, int &y) {
int x0, y0;
if (b == 0) {
x = 1;
y = 0;
return;
}
euclid(b, a % b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
int main() {
int t, x, y, a, b, d;
fin >> t;
while (t --) {
fin >> a >> b >> d;
euclid(a, b, x, y);
if (d % __gcd(a, b) == 0) {
fout << x * (d / __gcd(a, b)) << " " << y * (d / __gcd(a, b)) << "\n";
} else {
fout << "0 0\n";
}
}
return 0;
}