Pagini recente » Cod sursa (job #2349440) | Cod sursa (job #1641482) | Cod sursa (job #1494203) | Cod sursa (job #1291022) | Cod sursa (job #2978910)
#include <fstream>
#define ll long long
using namespace std;
ifstream cin ("euclid3.in");
ofstream cout ("euclid3.out");
void cmmdc (ll x,ll y,ll &d)
{
if (y== 0)
d = x;
else
cmmdc(y,x%y,d);
}
void euclid (ll x,ll y,ll &a,ll &b)
{
if (y == 0)
{
a = 1;
b = 0;
}
else
{
ll x1,y1;
euclid(y,x%y,x1,y1);
a = y1;
b = x1 - (x/y)*y1;
}
}
void solve ()
{
ll x,y,c;
cin >> x >> y >> c;
ll a,b,d;
cmmdc(x,y,d);
if (c%d!=0)
{
cout << "0 0" << '\n';
return;
}
euclid(x,y,a,b);
cout << a*c/d << ' ' << b*c/d << '\n';
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t)
{
t--;
solve();
}
return 0;
}