Pagini recente » Monitorul de evaluare | Diferente pentru home intre reviziile 642 si 643 | Clasament dupa rating | Monitorul de evaluare | Cod sursa (job #2214056)
#include <fstream>
using namespace std;
ifstream in("euclid3.in");
ofstream out("euclid3.out");
int cmmdc(int a, int b, int &x, int &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
int ans = cmmdc(b, a % b, x, y);
int aux = x;
x = y;
y = aux - (y * (a / b));
return ans;
}
int a, b, c, x, y;
int n;
int main() {
in >> n;
while (n --) {
in >> a >> b >> c;
x = y = 0;
int d = cmmdc(a, b, x, y);
if (c % d == 0)
out << x * c / d << ' ' << y * c / d << '\n';
else
out << "0 0\n";
}
return 0;
}