Cod sursa(job #2460815)
| Utilizator | Data | 24 septembrie 2019 15:25:28 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.58 kb |
#include <bits/stdc++.h>
#define l long long
using namespace std;
void euclid(l a, l b, l& d, l& x, l&y) {
if(b == 0) { d = a; x = 1; y = 0; return; }
l x0, y0; euclid(b, a % b, d, x, y);
x0 = y; y0 = x - (a / b) * y; x = x0; y = y0;
}
int main() {
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
l t, a, b, c, x, y, d; fin >> t;
do {
fin >> a >> b >> c; euclid(a, b, d, x, y);
if(c % d)
fout << "0 0\n";
else
((fout << x * c / d).put(' ') << y * c / d).put('\n');
} while(--t);
}