Pagini recente » Cod sursa (job #39478) | Cod sursa (job #100884) | Cod sursa (job #652817) | Cod sursa (job #879275) | Cod sursa (job #3217710)
#include <iostream>
#include <fstream>
#include <stdint.h>
void Euclid(int64_t a, int64_t b, int64_t& d, int64_t& x, int64_t& y) {
if(!b) {
d = a;
x = 1;
y = 0;
} else {
int64_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");
int64_t t;
fin >> t;
for(int64_t i = 0; i != t; ++i) {
int64_t a, b, c;
fin >> a >> b >> c;
int64_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;
}