Pagini recente » Cod sursa (job #2957808) | Cod sursa (job #427173) | Cod sursa (job #2461781) | Cod sursa (job #1678813) | Cod sursa (job #2909363)
#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) {
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';
}
}
}