Pagini recente » Istoria paginii runda/sacou/clasament | Cod sursa (job #2404586) | Cod sursa (job #3296756) | Istoria paginii runda/sacou/clasament | Cod sursa (job #2404272)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("euclid3.in");
ofstream fout ("euclid3.out");
void euclid(long a, long b, long &x, long &y, long &d){
if(b == 0){
d = a;
x = 1;
y = 0;
}else{
long x0, y0;
euclid(b, a % b, x0, y0, d);
x = y0;
y = x0 - (a/b) * y0;
}
}
int T;
long a, b, c;
int main()
{
fin >> T;
for(int i = 1; i <= T; ++i){
fin >> a >> b >> c;
long x, y, d;
euclid(a, b, x, y, d);
if(c % d)
fout << "0 0\n";
else
fout << x * (c/d) << " " << y * (c/d) << "\n";
}
fin.close();
fout.close();
return 0;
}