Pagini recente » Cod sursa (job #2968033) | Cod sursa (job #2505956) | Cod sursa (job #680068) | Istoria paginii runda/sim01/clasament | Cod sursa (job #2702499)
#include <fstream>
using namespace std;
void euclid(int a, int b, int &d, int &x, int &y) {
if(b == 0) {
d = a;
x = 1, y = 1;
}
else {
int x1 , y1;
euclid(b , a % b , d, x1 , y1);
x = y1;
y = x1 - a / b * y1;
}
}
int main() {
int t, a, b, c, cmmdc, x, y;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
f >> t;
while (t--) {
f >> a >> b >> c;
euclid(a, b, cmmdc, x, y);
if (c % cmmdc)
g << 0 << ' ' << 0 << '\n';
else
g << x * (c / cmmdc) << ' ' << y * (c / cmmdc) << '\n';
}
f.close();
g.close();
return 0;
}