Pagini recente » Cod sursa (job #3319534) | Cod sursa (job #1209589) | Cod sursa (job #1496140) | Cod sursa (job #2518111) | Cod sursa (job #3310911)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
long long n;
long long euclid(long long a, long long b, long long &x, long long &y)
{
if(b==0){
x=1, y=0;
return a;
}
else{
long long x1, y1, d;
d = euclid(b,a%b,x1,y1);
x = y1;
y = x1 - (a/b)*y1;
return d;
}
}
int main()
{
fin>>n;
for(int i=1; i<=n; i++){
long long a, b, c, d, x, y;
fin>>a>>b>>c;
d = euclid(a,b,x,y);
if(c%d) fout<<"0 0\n";
else fout<<x*(c/d)<<" "<<y*(c/d)<<"\n";
}
}