Pagini recente » Cod sursa (job #1240024) | Cod sursa (job #1235875) | Cod sursa (job #376754) | Cod sursa (job #53366) | Cod sursa (job #1199518)
#include<iostream>
#include<fstream>
using namespace std;
long long gcd(long long a, long long b, long long &x, long long&y){
if (b == 0){
x = 1;
y = 0;
return a;
}
long long x0, y0, d;
d = gcd(b, a%b, x0, y0);
x = y0;
y = x0 - (a / b)*y0;
return d;
}
int main(){
ifstream f("euclid3.in", ios::in);//Change the name
ofstream g("euclid3.out", ios::out);//Change the name
int T;
long long a, b, c;
f >> T;
for (T; T > 0; T--){
f >> a >> b >> c;
long long x, y,d;
d = gcd(a, b, x, y);
if (c%d)
g << "0 0\n";
else g << x*(c/d) << " " << y*(c/d) << '\n';
}
f.close();
g.close();
return 0;
}