Pagini recente » Cod sursa (job #326362) | Cod sursa (job #1939407) | Cod sursa (job #2762270) | Cod sursa (job #3292082) | Cod sursa (job #3200016)
#include <bits/stdc++.h>
#define int long long
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int modular_inverse(int a, int b, int &x, int &y){
if(b == 0){
x = 1;
y = 0;
return a;
}
else {
int x0, y0, d;
d = modular_inverse(b, a % b, x0, y0);
x = y0;
y = x0 - a / b * y0;
return d;
}
}
int Q, a, b, c, x, y, d;
int32_t main(){
fin >> Q;
while(Q--){
fin >> a >> b >> c;
d = modular_inverse(a, b, x, y);
if(c % d){
fout << "0 0\n";
continue;
}
fout << x * c / d << " " << y * c / d << "\n";
}
}