Pagini recente » Borderou de evaluare (job #1139704) | Cod sursa (job #2562001)
#include <bits/stdc++.h>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
void Euclid(int a,int b,int &x,int &y,int &d)
{
if( b== 0 )
{
d=a;
x=1;
y=0;
return;
}
int x0,y0;
Euclid(b,a%b,x0,y0,d);
x=y0;
y=x0-(a/b)*y0;
}
int main()
{
int T,a,b,c;
f>>T;
for(int t=1;t<=T;t++)
{
f>>a>>b>>c;
int x,y,d;
Euclid(a,b,x,y,d);
if( c%d == 0 )
g<<x*(c/d)<<' '<<y*(c/d)<<'\n';
else
g<<0<<' '<<0<<'\n';
}
return 0;
}