/BCMATHP - Lũy thừa 2

<Problem>

https://www.spoj.com/PTIT/problems/BCMATHP/
              #include <iostream>
        #include <string>
        using namespace std;
         
        string prod(string s1, string s2) {
          int* c = new int[s1.length() + s2.length() + 1] { 0 };
         
          for (int i = s1.length() - 1; i >= 0; i--) {
            for (int j = s2.length() - 1; j >= 0; j--) {
              int a = s1[i] - '0';
              int b = s2[j] - '0';
              c[i + j] = c[i + j] + a * b;
            }
          }
          string s3 = "";
          for (int i = s1.length() + s2.length() - 1 - 1; i >= 1; i--) {
            c[i - 1] = c[i - 1] + (c[i] / 10);
            c[i] = c[i] % 10;
            s3 = (char)(c[i] + '0') + s3;
          }
          //cout << s3 << endl;
          string sub = to_string(c[0]);
          s3 = sub + s3;
          while (s3[0] == '0' && s3.length() > 1) s3.erase(0, 1);
          return s3;
        }
         
        int main() {
          int a, b;
          cin >> a >> b;
          string s = "1";
          for (int i = 1; i <= a; i++) {
            s = prod("2", s);
          }
          for (int i = a + 1; i <= 62; i++) {
            s = prod("2", s);
            
            int n = s[0] - '0';
            if (n == b) {
              cout << i << endl;
              return 0;
            }
          }
          cout << 0 << endl;
          return 0;
        }