Cod sursa(job #1257844)
| Utilizator | Data | 8 noiembrie 2014 11:45:48 | |
|---|---|---|---|
| Problema | Invers modular | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | cls6ichbsim1 | Marime | 0.41 kb |
#include <fstream>
#include <cmath>
using namespace std;
ifstream in ("inversmodular.in");
ofstream out ("inversmodular.out");
int q;
long long pow(int x,int y)
{ if(y==1)
return x;
long long val=pow(x,y/2);
if(y%2==1)
return val*val%q*x%q;
return val*val%q;
}
int main()
{
long long a,n,k;
in>>a>>n;
k=pow(a,n-2);
out<<k%n;
return 0;
}
