Pagini recente » Cod sursa (job #3292016) | Cod sursa (job #3293899) | Cod sursa (job #3290642)
#include<bits/stdc++.h>
using namespace std;
void euclid(int a , int b ,int & d, int & x, int & y)
{
if(b == 0)
{
d = a;
x = 1, y = 0;
}
else
{
int x1 , y1;
euclid(b , a % b , d, x1 , y1);
x = y1;
y = x1 - (a / b) * y1;
}
}
int main()
{
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
int t;
cin >> t;
while(t--)
{
int a, b, c, x, y, ans;
cin >> a >> b >> c;
euclid(a, b, ans, x, y);
if(c % ans)
{
cout << "0 0\n";
}
else
{
cout << x * (c / ans) << " " << y * (c / ans) << "\n";
}
}
}