http://www.spoj.com/problems/POWERUP/#

#include<stdio.h>
int p(long long int,long long int,long long int );
int main()
{

	long long int a,b,c,m=1000000007,s,ans;

	while(1)
	{
			scanf("%lld%lld%lld",&a,&b,&c);
		if(a==-1&&b==-1&&c==-1)
		break;
	else
	{
	s=p(b,c,m);
	
	ans=p(a,s,m);
	printf("%lld\n",ans);
}

}
return(0);
}
int p(long long int a,long long int n,long long int m)
{
long long int res=1;
while(n)
{
if(n&1)
{
res=(resa)%m;
–n;
}
else
{
a=(a
a)%m;
n>>=1;
}
}
return(res);
}

your code gives 1 for a=2 b=3 c=2 and if m=5 (prime) but it should give 2…
(2^(3^2))%5=2
but according to your code
(3^2)%5=4
(2^4)%5=1
so this is wrong…

Actually, I wanted to become a programmer and need to learn such best essays things which are impressive and thoughtful thanks for sharing it. Thanks for sharing the code with us hope that be useful and I can get help if I face such problem.

can any one please point out my mistake