Pagini recente » Cod sursa (job #2656439) | Cod sursa (job #2666816) | Cod sursa (job #909435) | Cod sursa (job #2647541) | Cod sursa (job #3004058)
#include <bits/stdc++.h>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
typedef long long ll;
long long a,b,c;
void euclidExtins(ll a,ll b,ll &x,ll &y)
{
if (b==0)
{
x=1;
y=0;
return;
}
long long c = a/b;
long long x2,y2;
euclidExtins(b,a%b,x2,y2);
x = y2;
y = x2-c*y2;
}
ll t,gcd;
pair <ll,ll> hello;
int main()
{
f>>t;
for (;t--;)
{
f>>a>>b>>c;
gcd = __gcd(a,b);
if (c%gcd!=0)
{
g<<"0"<<" "<<"0"<<'\n';
}
else
{
long long x,y;
euclidExtins(a,b,x,y);
g<<x*(c/gcd)<<" "<<y*(c/gcd)<<'\n';
}
}
return 0;
}