Pagini recente » Cod sursa (job #3244641) | Cod sursa (job #3190018) | Cod sursa (job #818874) | Cod sursa (job #30797) | Cod sursa (job #2047696)
#include <fstream>
using namespace std;
ifstream f("euclid.in");
ofstream g("euclid.out");
int a,b,c,i,n,d,x,y;
int euclid1(int a,int b,int &x,int &y)
{
if(b==0)
{
x=1;
y=0;
return a;
}
int x0,y0;
d=euclid1(b,a%b,x0,y0);
x=y0;
y=x0-(a/b)*y0;
return d;
}
int main()
{
f>>n;
for(i=1;i<=n;i++)
{
f>>a>>b>>c;
d=euclid1(a,b,x,y);
if(c%d)g<<"0"<<" "<<"0"<<'\n';
else g<<x*(c/d)<<" "<<y*(c/d)<<'\n';
}
return 0;
}