Pagini recente » Monitorul de evaluare | Cod sursa (job #2409578) | Cod sursa (job #656893)
Cod sursa(job #656893)
#include<fstream>
using namespace std;
ifstream in("euclid3.in");
ofstream out("euclid3.out");
long t,a,b,c,d,x,y;
long euclid ( long a, long b)
{
long cx,cy,rez;
if ( b==0 )
{
x=1;
y=0;
return a;
}
rez=euclid ( b,a%b );
cx=x;
cy=y;
x=cy;
y=cx-(a/b)*cy;
return rez;
}
int main()
{
in>>t;
for ( ; t; t-- )
{
in>>a>>b>>c;
d=euclid(a,b);
if ( c%d==0 )
out<<x*(c/d)<<" "<<y*(c/d)<<"\n";
else
out<<"0 0\n";
}
}