Cod sursa(job #1354686)
| Utilizator | Data | 21 februarie 2015 22:55:52 | |
|---|---|---|---|
| Problema | Invers modular | Scor | 50 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.46 kb |
#include <iostream>
#include <fstream>
#define LL long long int
using namespace std;
LL A,B;
void gcdext(LL a, LL b,LL &x,LL &y){
if (b==0){
x=1;
y=0;
return;
}
LL x0,y0;
gcdext(b,a%b,x0,y0);
x=y0;
y=x0-y0*(a/b);
}
int main(){
ifstream fin("inversmodular.in");
ofstream fout("inversmodular.out");
fin >> A >> B;
LL x,y;
gcdext(A,B,x,y);
fout << x;
return 0;
}
