Cod sursa(job #1919838)
Utilizator | Data | 9 martie 2017 21:16:03 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <cstdio>
using namespace std;
const int mod=1999999973;
int rid_put(int a,int b)
{
int sol=1;
for(int i=0;(1<<i)<=b;i++)
{
if(b&(1<<i)) sol=(1LL*sol*a)%mod;
a=(1LL*a*a)%mod;
}
return sol;
}
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
int n,p;
scanf("%d%d",&n,&p);
printf("%d",rid_put(n,p));
return 0;
}