Cod sursa(job #1251881)
Utilizator | Data | 29 octombrie 2014 23:10:09 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | c | Status | done |
Runda | Arhiva educationala | Marime | 0.52 kb |
#include <stdio.h>
#define IN "lgput.in"
#define OUT "lgput.out"
typedef unsigned long long Int;
static const Int mod = 1999999973;
static Int lgput(Int n, Int p)
{
Int l;
if (p == 0)
return 1;
if (p == 1)
return n;
l = lgput(n, p >> 1);
if (p % 2)
return l * l % mod * r % mod;
return l * l % mod;
}
int main(void)
{
Int p, n;
freopen(IN, "r", stdin);
freopen(OUT, "w", stdout);
scanf("%llu %llu", &n, &p);
printf("%llu\n", lgput(n, p));
return 0;
}