i have made a way to assign the last number but on uploading it on spoj it says wrong answer . can anyone can help to sort out this problem.
my code is:
#include
#include
using namespace std;
int main()
{
short int t;
cin>>t;
if(t<=30)
{while(t-- )
{short int a;
short int r=0;
long long int b,c;
cin>>a>>b;
if(a==0 && b==0)
{
break;
}
else if(b==0)
{
cout<<“1\n”;
}
else if(a==0)
{
cout<<“0\n”;
}
else
{
r=b%4;
if(r==0)
{
c=a%2;
if(c==0)
cout<<“6\n”;
else if(c==1)
cout<<“1\n”;
}
else
{
c=pow(a,r);
c=c%10;
cout<<c<<endl;
}
}
}
}
return 0;
}