Pagini recente » Cod sursa (job #2940814) | Cod sursa (job #141138) | Cod sursa (job #923519) | Cod sursa (job #2673733) | Cod sursa (job #2050503)
#include <iostream>
#include <fstream>
#define ll long long
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
ll n, a1, b1, c1, x, y, nr;
int gcd(ll &x, ll &y, ll a, ll b)
{
if(b==0)
{
x=1;
y=0;
return a;
}
else
{
nr=gcd(x,y,b,a%b);
ll aux=x;
x=y;
y=aux-y*(a/b);
}
return nr;
}
void citire()
{
int i;
f>>n;
for(i=1; i<=n; i++)
{
f>>a1>>b1>>c1;
x=y=0;
nr=gcd(x,y,a1,b1);
if(c1%nr==0) g<<x*(c1/nr)<<' '<<y*(c1/nr)<<'\n';
else g<<0<<' '<<0<<'\n';
}
}
int main()
{
citire();
return 0;
}