Pagini recente » Cod sursa (job #2627421) | Cod sursa (job #1651705) | Cod sursa (job #2653070) | Cod sursa (job #3164863) | Cod sursa (job #2121203)
#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;
while(t2){
r=t1%t2;
t1=t2;
t2=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;
}