Cod sursa(job #211850)
Utilizator | Data | 3 octombrie 2008 18:55:14 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.3 kb |
#include<math.h>
#include<stdio.h>
int main()
{
long long n,p,s,x;
n=0;
p=0;
freopen("1gput.in","r",stdin);
freopen("1gput.out","w",stdout);
scanf("%lld%lld",&n,&p);
s=1;
while(p)
{
if(p%2)
s=(s*n)%1999999973;
n=(n*n)%1999999973;
p=p/2;
}
printf("%lld",s);
return 0;
}