#include #include std::string find_operations(int N) { if (N == 1) return ""; std::string operations; while (N > 1) { if ((N - 1) % 3 == 0) { N = (N - 1) / 3; operations += 'B'; } else { N = (N - 1) / 2; operations += 'A'; } } // Reverse the string to get operations from x=1 to x=N reverse(operations.begin(), operations.end()); return operations; } int main() { int N; std::cin >> N; std::string result = find_operations(N); std::cout << result << std::endl; return 0; }