Pagini recente » Cod sursa (job #135622) | Cod sursa (job #3290498) | Cod sursa (job #9450) | Cod sursa (job #2765968) | Cod sursa (job #2462275)
#include <bits/stdc++.h>
using namespace std;
int euc(int a, int b, int& x, int& y)
{
if(b == 0)
{
x = 1;
y = 0;
return a;
}
int x0, y0;
int d = euc(b, a % b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
return d;
}
int main()
{
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
int n;
cin >> n;
while(n--)
{
int a, b, d, x, y, c;
cin >> a >> b >> c;
d = euc(a, b, x, y);
if(c % d == 0)
{
int m = c / d;
cout << x * m << " " << y * m << '\n';
}
else cout << "0 0\n";
}
return 0;
}