Pagini recente » Cod sursa (job #3266101) | Cod sursa (job #3293110) | Cod sursa (job #1954260) | Cod sursa (job #3279498) | Cod sursa (job #3251739)
#include <iostream>
#include <algorithm>
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int ee(int &x,int &y,int a,int b){
if(!b){
x=1;
y=0;
return a;
}
else{
int x0,y0,d;
d=ee(x0,y0,b,a%b);
x0=y0;
y0=x0-y0*(a/b);
return d;
}
}
int t,a,b,c;
int main()
{
fin>>t;
for(int i=0;i<t;i++){
fin>>a>>b>>c;
int x,y,d=ee(x,y,a,b);
if(c%d==0)
fout<<x*c/d<<' '<<y*c/d<<'\n';
else
fout<<"0 0\n";
}
return 0;
}