Cod sursa(job #2331252)
Utilizator | Data | 29 ianuarie 2019 13:30:14 | |
---|---|---|---|
Problema | Invers modular | Scor | 50 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <fstream>
using namespace std;
ifstream fin("inversmodular.in");
ofstream fout("inversmodular.out");
int a, x, m, y;
void euclid(int a, int b, int &x, int &y){
if(b == 0){
x = 1;
y = 0;
return;
}
int x0, y0;
euclid(b, a%b, x0, y0);
x = y0;
y = x0 - y0*(a/b);
}
int main(){
fin>>a>>m;
euclid(a, m, x, y);
fout<<x;
return 0;
}