Pagini recente » Pachetul de instalare | Cod sursa (job #1116729) | Cod sursa (job #3290844) | Cod sursa (job #228317) | Cod sursa (job #3257890)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
long long euclid(long long a,long long b, long long &x, long long &y)
{
if(b==0)
{
x=1;
y=0;
return a;
}
else
{
long long x0,y0;
long long d= euclid(b,a%b,x0,y0);
x=y0;
y=x0-a/b*y0;
return d;
}
}
int main()
{
long long a,b,c,t;
f>>t;
for(int i=1;i<=t;i++)
{
f>>a>>b>>c;
long long x,y;
long long d= euclid(a,b,x,y);
if(c%d==0)
{
x*=c/d;
y*=c/d;
g<<x<<" "<<y<<endl;
}
else
g<<"0 0"<<endl;
}
return 0;
}