Pagini recente » Cod sursa (job #1187107) | Rating Beznea Mircea-Andrei (mirceabezneaandrei) | Cod sursa (job #1133007) | Cod sursa (job #2719628) | Cod sursa (job #1857252)
#include <fstream>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int x, y, n, m, a, b, d;
inline int cmmdc(int x, int y, int &a, int &b) {
if (y == 0) {
a = 1, b = 0;
return x;
}
int xx=0, yy=0, d = cmmdc(y, x%y, xx, yy);
a = yy;
b = xx-(x/y)*yy;
return d;
}
int main() {
f >> n;
int x, y, c, a, b;
while (n--) {
f >> x >> y >> c;
a=b=0;
d = cmmdc(x, y, a, b);
if (c%d==0)
g << (1LL*x*c)/d << ' ' << (1LL*y*c)/d << '\n';
else g <<"0 0\n";
}
return 0;
}