Cod sursa(job #562713)
Utilizator | Data | 23 martie 2011 18:59:27 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <stdio.h>
using namespace std;
const int mod = 1999999973;
unsigned N, P, rez, next;
int main()
{
freopen ("lgput.in","r",stdin);
freopen ("lgput.out","w",stdout);
scanf("%u %u",&N,&P);
rez = 1;
while(P)
{
if(P & 1)
rez *= N;
N *= N;
N %= mod;
rez %= mod;
P >>= 1;
}
printf("%u\n",rez);
return 0;
}