Pagini recente » Cod sursa (job #1922664) | Cod sursa (job #2231736) | Cod sursa (job #392521) | Cod sursa (job #2099678) | Cod sursa (job #1373014)
#include <fstream>
using namespace std;
ifstream in ("euclid3.in");
ofstream out ("euclid3.out");
int x, y, d;
void EE(int a, int b, int &x, int &y) {
if (b == 0) {
d = a;
x = 1;
y = 0;
return ;
}
EE(b, a % b, x, y);
int aux = x;
x = y;
y = aux - y * (a / b);
}
int main() {
int t, a, b, c;
in >> t;
while (t--) {
in >> a >> b >> c;
x = 1;
y = 0;
EE(a, b, x, y);
if (c % d == 0)
out << x * (c / d) << ' ' << y * (c / d) <<'\n';
else
out << 0 << ' ' << 0 << '\n';
}
in.close();
out.close();
return 0;
}