Pagini recente » Cod sursa (job #2555059) | Cod sursa (job #2900855) | Cod sursa (job #3138794) | Cod sursa (job #2605206) | Cod sursa (job #2900837)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("test.in");
ofstream fout ("test.out");
int a,n;
long long RidicareLaPutere (int x, int e){
if (e==0)
return 1;
if (e==1)
return x;
long long rez=1;
while (e){
if (e%2==1)
rez=rez*x%n;
x=x*x%n;
e/=2;
}
return rez;
}
int main()
{
fin >>a>>n;
fout <<RidicareLaPutere (a,n-2);
fin.close ();
fout.close ();
return 0;
}