Pagini recente » Cod sursa (job #564908) | Cod sursa (job #899444) | Cod sursa (job #1917560) | Cod sursa (job #2596664) | Cod sursa (job #3214565)
#include <iostream>
#define int long long
using namespace std;
void euclid(int a, int b, int &d, int &x, int &y) {
if(!b) {
d = a;
x = 1, y = 1;
}
else {
int x1, y1;
euclid(b, a%b, d, x1, y1);
x = y1;
y = x1 - a / b * y1;
}
}
int32_t main()
{
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
cin.tie(nullptr)->sync_with_stdio(0);
int tt;
cin >> tt;
while(tt--) {
int a, b, c, d, x, y;
cin >> a >> b >> c;
euclid(a, b, d, x, y);
if(c % d)
cout << "0 0\n";
else
cout << x * (c / d) << ' ' << y * (c / d) << '\n';
}
return 0;
}