Pagini recente » Cod sursa (job #3296757) | Profil deniros14 | Cod sursa (job #1932634) | Cod sursa (job #2069600) | Cod sursa (job #2404235)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("euclid3.in");
ofstream fout ("euclid3.out");
long euclid(long a, long b, long &x, long &y){
long x0, y0, d;
if(b == 0){
x = 1;
y = 0;
return a;
}
d = euclid(b, a % b, x0, y0);
x = y0;
y = x0 - (a/b) * y0;
return d;
}
int T;
long a, b, c;
int main()
{
fin >> T;
for(int i = 1; i <= T; ++i){
long x, y;
fin >> a >> b >> c;
long d = euclid(a, b, x, y);
if(c % d)
cout << "0 0\n";
else
cout << x * (c/d) << " " << y *(c/d) << "\n";
}
fin.close();
fout.close();
return 0;
}