Pagini recente » Cod sursa (job #3254976) | Cod sursa (job #1576795) | Cod sursa (job #2951490) | Cod sursa (job #1353445) | Cod sursa (job #504018)
Cod sursa(job #504018)
#include <stdio.h>
#define NUMBER 1999999973
unsigned int pow_log(unsigned int n, unsigned int p)
{
unsigned int res=1, tmp=n;
while ( p != 0)
{
if ( p%2 == 0)
{
p /= 2;
tmp *= tmp;
}
else
{
--p;
res *= tmp;
}
}
return res;
}
int main(void)
{
unsigned int n, p;
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%u %u",&n, &p);
printf("%u\n",(pow_log(n,p) % NUMBER));
return 0;
}