Pagini recente » Monitorul de evaluare | Cod sursa (job #3142003) | Cod sursa (job #2218868) | Cod sursa (job #1267841) | Cod sursa (job #2728893)
#include<fstream>
using namespace std;
ifstream cin("euclid3.in");
ofstream cout("euclid3.out");
void euclid(int *d, int a, int b, int *x, int *y) {
if (b == 0) {
*d = a;
*x = 1;
*y = 0;
} else {
int x0, y0;
euclid(d, b, a % b, &x0, &y0);
*x = y0;
*y = x0 - (a / b) * y0;
}
}
int main() {
int t, d, a, b, c, x, y;
cin >> t;
while (t--) {
cin >> a >> b >> c;
euclid(&d, a, b, &x, &y);
if (c % d != 0)
cout << 0 << " " << 0 << "\n";
else
cout << x * (c / d) << " " << y * (c / d) << "\n";
}
}