Cod sursa(job #212184)
Utilizator | Data | 4 octombrie 2008 15:58:31 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <cstdio>
#define M 1999999973
long long n,p,pr;
void read(){
freopen("lgput.in","r",stdin);
scanf("%lld%lld",&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("%lld\n",pr%M);
}
int main(){
read();
solve();
write();
}