Pagini recente » Istoria paginii runda/cnrv_oji_x | Cod sursa (job #121374) | Cod sursa (job #1648634) | Cod sursa (job #1551639) | Cod sursa (job #3227069)
#include <iostream>
using namespace std;
void euclid(int a, int b, int &d, int &x, int &y) {
if(!b) {
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);
cin.tie(nullptr)->sync_with_stdio(0);
int tt;
cin >> tt;
while(tt--) {
int a, b, c, x, y, d;
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;
}