/* -*- coding: utf-8 -*- * * 2766.cc: No.2766 Delicious Multiply Spice - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_M = 60; /* typedef */ typedef long long ll; /* global variables */ char s[MAX_M + 4]; /* subroutines */ int rec(ll n, int k) { if (n <= 2) return (n == 1) ? k : 0; if ((n - 1) % 2 == 0) { s[k++] = 'A'; int m = rec((n - 1) / 2, k); if (m > 0) return m; k--; } if ((n - 1) % 3 == 0) { s[k++] = 'B'; int m = rec((n - 1) / 3, k); if (m > 0) return m; k--; } return 0; } /* main */ int main() { ll n; scanf("%lld", &n); int m = rec(n, 0); reverse(s, s + m); s[m] = '\0'; puts(s); return 0; }