Pagini recente » Cod sursa (job #1632427) | Cod sursa (job #2611187) | Cod sursa (job #93142) | Cod sursa (job #250496) | Cod sursa (job #2909364)
#include<fstream>
using namespace std;
ifstream cin("euclid3.in");
ofstream cout("euclid3.out");
int a, b, c, t;
int cmmdc(int x, int y) {
if (y == 0) {
return x;
}
else {
return cmmdc(y, x % y);
}
}
int main() {
cin >> t;
while (t > 0) {
t--;
cin >> a >> b >> c;
int d;
d = cmmdc(a, b);
if ((int)(c / d) * d == c) {
if (a == 0) {
cout << 10 << " " << c/b << '\n';
continue;
}
if (b == 0) {
cout << c/a << " " << 10 << '\n';
continue;
}
a = a * (c / d);
b = b * (c / d);
c = c * (c / d);
int x = 0, y = 0;
y = (c - a*x) / b;
while (a * x + b * y != c) {
x++;
y = (c - a * x) / b;
}
cout << x << " " << y << '\n';
}
else {
cout << 0 << " " << 0 << '\n';
}
}
}