Cod sursa(job #547365)
Utilizator | Data | 6 martie 2011 11:58:23 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.29 kb |
#include<stdio.h>
int n,p,k;
int main(){
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%d %d",&n,&p);
k=p;
p=1;
while (k>0){
if (k%2==0){
n=n*n;
k=k/2;
}
else {
p=p*n;
k=k-1;
}
p=p%1999999973;
}
printf("%d",p);
return(0);
}