Cod sursa(job #2638435)
Utilizator | Nagy Boglarka bogikanagy | Data | 28 iulie 2020 11:30:21 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
//#include <iostream>
#include <fstream>
#define P 1999999973
using namespace std;
ifstream cin ("lgput.in");
ofstream cout ("lgput.out");
int n,p,k;
int gyorsh (long long a, int n)
{
long long res=1;
while (n>0)
{
if (n&1) res=(res*a)%P;
n>>=1;
a=(a*a)%P;
}
return res%P;
}
int main()
{
ios::sync_with_stdio(false);
cin>>n>>p;
k=gyorsh(n,p);
cout<<k;
return 0;
}