Pagini recente » Cod sursa (job #1223216) | Cod sursa (job #1693298) | Cod sursa (job #2424352) | Cod sursa (job #364470) | Cod sursa (job #2066415)
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
void euclid(int a, int b, int &d, int &x, int &y) {
if (b == 0) {
d = a;
x = 1;
y = 0;
return ;
}
int x0, y0;
euclid(b, a % b, d, x0, y0);
x = y0;
y = x0 - ((a / b) * y0);
}
int main() {
int t;
fin >> t;
for (; t; t--) {
int a, b, c;
fin >> a >> b >> c;
int x, y, d;
euclid(a, b, d, x, y);
if (c % d) x = y = 0;
fout << x * (c / d) << ' ' << y * (c / d) << '\n';
}
return 0;
}