Cod sursa(job #696758)
Utilizator | Data | 28 februarie 2012 19:56:45 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.26 kb |
#include<cstdio>
#define c 1999999973
long long n,p,x;
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld%lld", &n, &p);
x=1;
while(p)
{
if(p%2)
x=(x*n)%c;
n=(n*n)%c;
p/=2;
}
printf("%lld\n",x);
}