Pagini recente » Cod sursa (job #708629) | Cod sursa (job #331022) | Cod sursa (job #1707830) | Cod sursa (job #304899) | Cod sursa (job #3312920)
#include <iostream>
#include <fstream>
#include <stdint.h>
void Euclid(int32_t a, int32_t b, int32_t& d, int32_t& x, int32_t& y) {
if(!b) {
d = a;
x = 1;
y = 0;
} else {
int32_t x0, y0;
Euclid(b, a % b, d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main() {
std::ifstream fin("euclid3.in");
std::ofstream fout("euclid3.out");
int32_t t;
fin >> t;
while(t--) {
int32_t a, b, c;
fin >> a >> b >> c;
int32_t d, x, y;
Euclid(a, b, d, x, y);
if(c % d) {
fout << "0 0\n";
} else {
x *= c / d;
y *= c / d;
fout << x << ' ' << y << '\n';
}
}
fin.close();
fout.close();
return 0;
}