Cod sursa(job #492749)
| Utilizator | Data | 15 octombrie 2010 18:57:32 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.37 kb |
#include <stdio.h>
int main(){
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
long long n, p, sol=1, c=1999999973;
scanf("%lld %lld", &n, &p);
while(p){
if(p%2==1){
sol*=n;
sol%=c;
}
n*=n;
n%=c;
p/=2;
}
printf("%lld\n",sol);
return 0;
}
