Pagini recente » Cod sursa (job #1175422) | Cod sursa (job #609433) | Cod sursa (job #632791) | Cod sursa (job #2746334) | Cod sursa (job #2058515)
#include <fstream>
using namespace std;
ifstream cin("euclid3.in");
ofstream cout("euclid3.out");
void euclid(int a, int b, int &d, int &x, int &y) {
if (not b) {
d = a;
x = 1;
y = 0;
return;
}
int x0, y0;
euclid(b, a % b, d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
int main(int argc, char const *argv[]) {
int n;
cin >> n;
int a, b, c, d, x, y;
while (n --) {
cin >> a >> b >> c;
euclid(a, b, d, x, y);
if (c % d == 0) {
cout << x * c / d << ' ' << y * c / d << '\n';
}
else {
cout << 0 << ' ' << 0 << '\n';
}
}
}