Cod sursa(job #2744951)
| Utilizator | Data | 25 aprilie 2021 16:27:16 | |
|---|---|---|---|
| Problema | Invers modular | Scor | 50 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <iostream>
#include <fstream>
using namespace std;
void euclid( int a, int b, int& x, int& y ) {
if ( b == 0 ) {
x = 1;
y = 0;
} else {
int x0, y0;
euclid( b, a % b, x0, y0 );
x = y0;
y = x0 - (int)( a / b ) * y0;
}
}
int main() {
ifstream fin( "inversmodular.in" );
ofstream fout( "inversmodular.out" );
int a, b, x, y;
fin >> a >> b;
euclid( a, b, x, y );
fout << x;
return 0;
}
