Pagini recente » Cod sursa (job #679662) | Cod sursa (job #396275) | Cod sursa (job #373862) | Cod sursa (job #1061088) | Cod sursa (job #2737284)
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << " = " << x << "\n";
ifstream in("euclid3.in");
ofstream out("euclid3.out");
int t;
int a, b, d;
void gcd(int a, int b, int &x, int &y) {
int x0, y0;
if (b == 0) {
x = 1;
y = 0;
return;
}
gcd(b, a % b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
int main() {
in >> t;
for (int tt = 0; tt < t; tt++) {
in >> a >> b >> d;
if (d % __gcd(a, b) == 0) {
int x, y;
gcd(a, b, x, y);
out << (d / __gcd(a, b)) * x << " " << (d / __gcd(a, b)) * y << "\n";
} else {
out << "0 0\n";
}
}
return 0;
}