Pagini recente » Cod sursa (job #2198650) | Cod sursa (job #2604408) | Cod sursa (job #3131732) | Cod sursa (job #476791) | Cod sursa (job #2743220)
#include <bits/stdc++.h>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int t;
long long euclid_extins(int a, int b, long long &x, long long &y)
{
if(a==0)
{
x = 0;
y = 1;
return b;
}
long long x0, y0;
long long d = euclid_extins(b%a,a,x0,y0);
x = y0-(b/a)*x0;
y = x0;
return d;
}
int main()
{
f>>t;
for(int test=1;test<=t;test++)
{
int a,b,c;
f>>a>>b>>c;
long long x,y;
long long d = euclid_extins(a,b,x,y);
if(c%d!=0)
{
g<<0<<' '<<0<<'\n';
continue;
}
g<<1LL*x*(c/d)<<' '<<1LL*y*(c/d)<<'\n';
}
return 0;
}