Cod sursa(job #212182)
Utilizator | Data | 4 octombrie 2008 15:53:36 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <cstdio>
#define M 1999999973
int n,p,pr;
void read(){
freopen("lgput.in","r",stdin);
scanf("%d%d",&n,&p);
}
void solve(){
pr=1;
while (p){
if (p%2)
pr=(pr*n)%M;
n*=n;
p/=2;
}
}
void write(){
freopen("lgput.out","w",stdout);
printf("%d\n",pr%M);
}
int main(){
read();
solve();
write();
}