Pagini recente » Cod sursa (job #1706219) | Cod sursa (job #2889906) | Cod sursa (job #1400265) | Cod sursa (job #2124058) | Cod sursa (job #1398390)
#include <iostream>
#include <fstream>
#define LL long long
using namespace std;
int gcd(LL &x,LL &y,int a,int b)
{
if(!b)
{
x=1;
y=0;
return a;
}
else
{
int d=gcd(x,y,b,a%b);
LL aux=x;
x=y;
y=aux - y * (a/b);
return d;
}
}
int main()
{
int n;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
f>>n;
for(int i=1;i<=n;i++)
{
int a,b,c,d;
LL x,y;
f>>a>>b>>c;
d=gcd(x,y,a,b);
if(c%d==0)
g<<x*(c/d)<<" "<<y*(c/d)<<"\n";
else
g<<0<<" "<<0<<"\n";
}
}