Cod sursa(job #3353031)
| Utilizator | Data | 3 mai 2026 19:34:29 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.59 kb |
#include <bits/stdc++.h>
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;
}
else{
int x0,y0;
euclid(b, a%b, d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main()
{
int n;
fin >> n;
while(n--){
int a, b, c;
fin >> a >> b >> c;
int d, x, y;
euclid(a, b, d, x, y);
fout << x << " " << y << '\n';
}
return 0;
}
