Pagini recente » Istoria paginii runda/4x4 | Cod sursa (job #2416094) | Cod sursa (job #2857182) | Cod sursa (job #134972) | Cod sursa (job #3129829)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int cmmdc(int a, int b, int &x, int &y) {
if(b == 0) {
x = 1;
y = 0;
return a;
}
else {
int x1, y1;
int sol = cmmdc(b, a % b, x1, y1);
x = x1;
y = x1 - (a/b) * y1;
return sol;
}
}
int main() {
int n, a, b, c;
fin >> n;
for(int i = 1; i <= n; i++) {
fin >> a >> b >> c;
int x, y;
int d = cmmdc(a, b, x, y);
if(c % d == 0) {
fout<< x * c / d << " " << y * c / d<< endl;
} else {
fout << "0 0"<< endl;
}
}
return 0;
}