#include #include #include #include #include #include #include #include #include #include #define INT long long using namespace std; INT n, m; INT dp[2][701]; INT cbit(INT n) { n = ((n >> 1)&(INT)0x5555555555555555) + (n&(INT)0x5555555555555555); n = ((n >> 2)&(INT)0x3333333333333333) + (n&(INT)0x3333333333333333); n = ((n >> 4)&(INT)0x0f0f0f0f0f0f0f0f) + (n&(INT)0x0f0f0f0f0f0f0f0f); n = ((n >> 8)&(INT)0x00ff00ff00ff00ff) + (n&(INT)0x00ff00ff00ff00ff); n = ((n >> 16)&(INT)0x0000ffff0000ffff) + (n&(INT)0x0000ffff0000ffff); n = ((n >> 32)&(INT)0x00000000ffffffff) + (n&(INT)0x00000000ffffffff); return n; } INT combi(INT n,INT r) { INT t, u, v; INT i; if (r < n - r) { t = n - r; u = r; } else { t = r; u = n - r; } v = 1; for (i = t + 1; i <= n; i++) v *= i; for (i = 1; i <= u; i++) v /= i; return v; } INT superFB(INT n) { INT t = 0; for (INT i = 2; i < n; i += 3) t += combi(n - 1, i); return t; } int main() { INT t,u,v; INT i, j,k,l; cin >> n; t = 0; i = 2; v = 0; while (t < n) { i++; v = t; t += superFB(i); } u = i; vector sfb; for (i = 0; i < (1 << (u-1)); i++) { if (cbit((i << 1) + 1) % 3 == 0) sfb.push_back((i << 1) + 1); } string str; for (i = 0; i < u; i++) { if ((sfb[n - v - 1] & (1 << i)) == 0) str = "3" + str; else str = "5" + str; } cout << str << endl; }