Pagini recente » Cod sursa (job #1892677) | Cod sursa (job #3205823) | Cod sursa (job #2156637) | Cod sursa (job #41896) | Cod sursa (job #2415793)
#include <iostream>
#include <fstream>
using namespace std;
int t,a,b,c,d,xans,yans;
int gcd(int t1,int t2){
int r;
do{
r=t1%t2;
t1=t2;
t2=r;
} while(t2);
return t1;
}
void euclid(int t1,int t2){
if(t2==0){
xans=1;
yans=0;
return;
}
euclid(t2,t1%t2);
int xa=xans,ya=yans;
xans=ya;
yans=xa-(t1/t2)*ya;
}
int main()
{
ifstream f ("euclid3.in");
ofstream g ("euclid3.out");
f>>t;
while(t--){
f>>a>>b>>c;
d=gcd(a,b);
if(c%d==0){
euclid(a,b);
g<<xans*(c/d)<<" "<<yans*(c/d)<<'\n';
} else g<<"0 0\n";
}
f.close ();
g.close ();
return 0;
}