Cod sursa(job #346451)
| Utilizator | Data | 7 septembrie 2009 21:01:29 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.35 kb |
#include<stdio.h>
long long N,M,z=1999999973;
long long p(long long x,long long y)
{int w;
if(y==0)
return 1;
else if(y%2==0)
{
w=p(x,y/2);
return (w*w)%z;
}
else
{
w=p(x,y-1);
return (w*x)%z;
}
}
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld%lld",&N,&M);
N=N%z;
printf("%lld",p(N,M));
}
