Easiest way to solve this problem


#1

int Solution::power(string s) {
int n=s.size();
int a[n+3];
a[0]=1;
int t=0,c=1;
while(1)
{

   for(int i=0;i<c;i++)
   {
       a[i]=(a[i]*2+t);
       t=a[i]/10;
       a[i]=a[i]%10;
       
   }
   while(t>0)
   {
       a[c++]=t%10;
       t/=10;
   }
   if(c==n)
   { int i;
       for(i=0;i<c;i++)
         if(a[i]!=s[c-1-i]-'0')break;
       if(i==c)
       return 1;
   }
   else if(c>n)
   return 0;

}
}