Pagini recente » Cod sursa (job #719490) | Cod sursa (job #2205286) | Cod sursa (job #1928524) | Cod sursa (job #1903686) | Cod sursa (job #2437506)
#include <iostream>
#include <fstream>
using namespace std;
void euclid(int a, int b, int *c,int *x, int *y){
if(b == 0){
*c = a;
*x = 1;
*y = 0;
} else {
int x0, y0;
euclid(b, a%b, c, &x0, &y0);
*x = y0;
*y = x0 - (a/b)*y0;}
}
int main(){
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int T, a, b, c, x, y, d;
fin >> T;
for(int i = 1;i<=T;i++){
fin >> a >> b >> c;
euclid(a, b, &d, &x, &y);
if (c % d != 0){
fout <<'0'<<" "<<'0'<<'\n';
}else{
fout << x*(c/d) <<" "<<y*(c/d)<<'\n';
}
}
return 0;
}