Pagini recente » Cod sursa (job #3188841) | Monitorul de evaluare | Cod sursa (job #1017509) | Diferente pentru problema/calancea intre reviziile 3 si 4 | Cod sursa (job #1257844)
#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;
}