Pagini recente » Cod sursa (job #3252576) | Cod sursa (job #2275411) | Cod sursa (job #2496745) | Cod sursa (job #1203049) | Cod sursa (job #3125327)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int t;
int a, b, c;
int euclidex(int a, int b, int &x, int &y){
if(b == 0){
x = 1;
y = 0;
return a;
}else{
int x1, y1;
int r = euclidex(b, a%b, x1, y1);
x = y1;
y = x1 - (a/b) * y1;
return r;
}
}
int main()
{
fin >> t;
for(int i=1;i<=t;i++){
fin >> a >> b >> c;
int x, y;
int d = euclidex(a, b, x, y);
if(c%d == 0){
fout << x*(c/d) << " " << y*(c/d) << "\n";
}else{
fout << "0 0\n";
}
}
return 0;
}