Pagini recente » Cod sursa (job #1355886) | Cod sursa (job #2601870) | Cod sursa (job #2635310) | Cod sursa (job #2679996) | Cod sursa (job #3004049)
#include <bits/stdc++.h>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
typedef long long ll;
long long a,b,c;
pair <ll,ll> euclidExtins(ll a,ll b)
{
if (a<b)
{
return euclidExtins(b,a);
}
if (a==1&&b==0)
{
return make_pair(1,0);
}
pair <ll,ll> hello = euclidExtins(b,a%b);
ll c = a/b;
return {hello.second,hello.first - c*hello.second};
}
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
{
a = a/gcd;
b = b/gcd;
c = c/gcd;
hello = euclidExtins(a,b);
if (a<b)
{
swap(hello.first,hello.second);
}
g<<hello.first*c<<" "<<hello.second*c<<'\n';
}
}
return 0;
}