Pagini recente » Cod sursa (job #143434) | Cod sursa (job #406572) | Istoria paginii propuneri/6-arhiva-educationala | Cod sursa (job #3286821) | Cod sursa (job #3258178)
#include <fstream>
using namespace std;
ifstream cin ("euclid3.in");
ofstream cout ("euclid3.out");
void euclid_extins (int a, int b, int &d, int &x, int &y) {
if (!b) {
d = a;
x = 1;
y = 0;
}
else {
int x0, y0;
euclid_extins (b, a % b, d, x0, y0);
x = y0;
y = x0 - a / b * y0;
}
}
int main () {
int t;
cin >> t;
while (t--) {
int a, b, c;
cin >> a >> b >> c;
int d = 0, x = 0, y = 0;
euclid_extins (a, b, d, x, y);
if (c % d)
cout << "0 0\n";
else
cout << x * (c / d) << ' ' << y * (c / d) << '\n';
}
return 0;
}