Cod sursa(job #2293734)
Utilizator | Data | 1 decembrie 2018 15:03:55 | |
---|---|---|---|
Problema | Invers modular | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include<bits/stdc++.h>
using namespace std;
ifstream f("inversmodular.in");
ofstream g("inversmodular.out");
typedef long long Int;
Int Mod,n,a;
Int putere(Int b, Int e)
{
if(e==0)
return 1LL;
Int r=putere(b,e/2);
r=r*r%Mod;
if(e%2)
r=r*b%Mod;
return e;
}
int main()
{
f>>a>>n;
Mod=n;
g<<putere(a,n-2);
return 0;
}