124의 나라 나는 4시간걸린거 몇분만에 푼거보고 현타왔다

아래가 내 결과물
숫자 25까지 쭉 써놓고 124에 맞춰서 옆에 써놓고 규칙찾는다고 막 난리쳤는데

#include <string>
using namespace std;
short getExpotential(int n)
{
    short result = (n % 3) - 1;
    if (result < 0)
        result = 2;
    return result;
}

string solution(int n)
{
    string answer = "";
    int repeat = n;
    long digit = 10;
    long result = long(1) << getExpotential(n);

    while ((repeat = (repeat-1)/3))
    {
        long next_digit = (long(1) << getExpotential(repeat)) * digit;
        result += next_digit;
        digit *= 10;
    }

    answer = to_string(result);
    return answer;
}

long쓴 이유는 숫자 커지면 자릿수 엄청 커져서 int로는 안되서

- dc official App