Wrong answer for very large no


#1

pls somebody tell me how to solve this thing. number length can be more than 64, which mean number can be greater than 2 ^ 64 (out of long long range)


#2

long long int convert(char c)
{
if(c==‘0’)
return 0;
else if(c==‘1’)
return 1;
else if(c==‘2’)
return 2;
else if(c==‘3’)
return 3;
else if(c==‘4’)
return 4;
else if(c==‘5’)
return 5;
else if(c==‘6’)
return 6;
else if(c==‘7’)
return 7;
else if(c==‘8’)
return 8;
else
return 9;
}
long long int cal(string a)
{
long long int l=a.size();
long long int calc=0;
long long int i=0;
for(i=0;i<a.size();i++)
{
long long int con=convert(a[i]);
calc=(long long int)calc+((long long int)con*(long long int)pow(10,l-i-1));
}
return calc;
}
int Solution::power(string A) {
long long int x=cal(A);
if(A.size()==1)
{
if(x==0 ||x==1 ||x==3 ||x==5 ||x==7 ||x==9)
return 0;
}
while(x!=1)
{
if(x%2!=0)
{
return 0;
}
x=x/2;
}
return 1;
}