#include #include #include #include #include #include using namespace std; #define ull unsigned long long int main(void) { int N; cin >> N; int M = 32; int count = 0; ull res; int m; for (m = 1; m < M; ++m) { unsigned long long u = 0; for (ull i = 0; i < (1 << (m-1)); ++i) { ull tar = i << 1; tar += 1; if (bitset<36>(tar).count() % 3 == 0) ++count; if (count == N) { res = tar; break; } } if (count == N) break; } bitset<36> b = res; for (int i = m-1; i >= 0; --i) { cout << (b[i] ? 5 : 3); } cout << endl; system("pause"); return 0; }