Pagini recente » Cod sursa (job #818286) | Cod sursa (job #5634) | Cod sursa (job #2807765) | Cod sursa (job #537133) | Cod sursa (job #3151202)
#include <bits/stdc++.h>
using namespace std;
int euclid_extins(int a, int b, int& d, int& x, int& y)
{
if(!b)
{
x = 1, y = 0, d = a;
return a;
}
int x0, y0;
int aux = euclid_extins(b, a % b, d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
return aux;
}
void solve()
{
int a, b, c, x, y;
cin >> a >> b >> c;
int cmmdc;
euclid_extins(a, b, cmmdc, x, y);
if(c % cmmdc != 0)
{
cout << "0 0\n";
return;
}
a = a * c / cmmdc;
b = b * c / cmmdc;
euclid_extins(a, b, c, x, y);
cout << x * c / cmmdc << ' ' << y * c / cmmdc << '\n';
}
int main()
{
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
int t;
cin >> t;
while(t --)
solve();
return 0;
}