Pagini recente » Cod sursa (job #5543) | Cod sursa (job #2409155) | Cod sursa (job #2532630) | Cod sursa (job #3284812) | Cod sursa (job #3296941)
#include<bits/stdc++.h>
using namespace std;
int64_t gcd(int64_t a, int64_t b, int64_t &x, int64_t &y) {
if (b == 0){
x = 1;
y = 0;
return a;
}
else{
int64_t x1, y1, d = gcd(b, a % b, x1, y1);
x = y1;
y = x1 - (a / b) * y1;
return d;
}
}
int main(){
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
int64_t t, a, b, c, d, x, y;
cin >> t;
for (int64_t i = 0; i < t; i++){
cin >> a >> b >> c;
d = gcd(a, b, x, y);
if (c % d != 0) {
cout << "0 0\n";
}
else{
cout << x * (c / d) << " " << y * (c / d) << "\n";
}
}
return 0;
}