Pagini recente » Cod sursa (job #1687405) | infoarena - te ajutam sa devii olimpic! | Cod sursa (job #1926161) | Cod sursa (job #934434) | Cod sursa (job #2034159)
#include <bits/stdc++.h>
#include <limits>
using namespace std;
typedef unsigned long long ll;
ifstream f("inversmodular.in");
ofstream g("inversmodular.out");
ll exp_log(ll n,ll e,ll mod)
{
ll sol=1;
while (e!=0)
{
if (e%2==1) sol*=n%mod;
n*=n%mod;
e/=2;
}
return sol%mod;
}
int main()
{
ll a,n;
f>>a>>n;
g<<exp_log(a,n-2,n);
return 0;
}