Pagini recente » Cod sursa (job #372749) | Cod sursa (job #2025260) | Cod sursa (job #422691) | Cod sursa (job #862447) | Cod sursa (job #1354678)
#include <iostream>
#include <fstream>
#define LL long long int
using namespace std;
LL T,gcd;
void gcdext(LL a, LL b,LL &x,LL &y){
if (b==0){
x=1;
y=0;
gcd=a;
return;
}
LL x0,y0;
gcdext(b,a%b,x0,y0);
x=y0;
y=x0-y0*(a/b);
}
int main(){
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
fin >> T;
LL a,b,c,x,y;
while (T--){
fin >> a >> b >> c;
gcdext(a,b,x,y);
if (c%gcd){
fout << "0 0\n";
return 0;
}
fout << x*c/gcd<< " " << y*c/gcd << "\n";
}
return 0;
}