Cod sursa(job #1331949)
| Utilizator | Data | 1 februarie 2015 14:03:53 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.74 kb |
#include <fstream>
using namespace std;
int d;
int main() {
int a, b, c, q, x, y, aux, T;
ifstream in("euclid3.in");
ofstream out("euclid3.out");
in >> T;
while(T--) {
in >> a >> b >> c;
x = 1;
y = 0;
while(a % b != 0) {
q = a / b;
// gcd
aux = b;
b = a % b;
a = aux;
// x & y
x = x - q * aux;
y = y - q * aux;
}
// gcd
d = b;
if(c % d == 0)
out << (x * (c / d)) << ' ' << (y * (c / d)) << '\n';
else
out << "0 0\n";
}
in.close();
out.close();
return 0;
}
