Cod sursa(job #868607)
Utilizator | Data | 31 ianuarie 2013 12:08:48 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <stdio.h>
int i,n,p;
int m=1999999973;
long long a,sol;
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%d %d", &n, &p);
sol=1;
a=n;
while(p)
{
if(p%2)
sol=(sol*a)%m;
p>>=1;
a=(a*a)%m;
}
printf("%lld\n",sol);
}