Pagini recente » Cod sursa (job #2385213) | Cod sursa (job #1000592) | Cod sursa (job #3291075) | Cod sursa (job #2723007) | Cod sursa (job #2121201)
#include <iostream>
#include <fstream>
using namespace std;
int a,b,c,x,y,xa,ya,t,d;
int gcd(int t1,int t2){
int r;
do{
r=t1%t2;
t1=t2;
t2=r;
}while(r);
return t1;
}
void euc(int t1,int t2){
if(t2==0){
x=1;
y=0;
return;
}
euc(t2,t1%t2);
xa=x;ya=y;
x=ya;
y=xa-(t1/t2)*ya;
}
int main()
{
ifstream f ("euclid3.in");
ofstream g ("euclid3.out");
f>>t;
for(int tst=1;tst<=t;tst++){
f>>a>>b>>c;
d=gcd(a,b);
if(c%d!=0)g<<"0 0\n";
else {
euc(a,b);
g<<x*(c/d)<<' '<<y*(c/d)<<'\n';
}
}
f.close();
g.close();
return 0;
}