Cod sursa(job #485810)
Utilizator | Data | 19 septembrie 2010 16:31:09 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.3 kb |
#include <stdio.h>
const int MOD = 1999999973;
int main() {
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
long long N, P, sol=1;
scanf("%lld %lld",&N,&P);
for(; P; P/=2) {
if(P%2==1) sol*=N, sol%=MOD;
N*=N; N%=MOD;
}
printf("%lld\n",sol);
return 0;
}