Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- using ll = long long;
- using ld = long double;
- int main()
- {
- vector<string> z1;
- // base 2 palindrom generator :
- string x = "1";
- z1.push_back(x);
- for (int i = 0; i < 50000; i++)
- {
- x = x + '1';
- string aux = x;
- vector<string> ax;
- ll x1 = 1, x2 = aux.size() - 2;
- while (aux.at(aux.size() / 2) != 0 && x1 <= x2)
- {
- aux.at(x1) = '0';
- aux.at(x2) = '0';
- ax.push_back(aux);
- x1 += 1;
- x2 -= 1;
- i += 1;
- if (i == 49999)
- {
- break;
- }
- }
- reverse(ax.begin(), ax.end());
- z1.insert(z1.end(), ax.begin(), ax.end());
- z1.push_back(x);
- }
- ll n;
- cin >> n;
- x = z1.at(n - 1);
- ll ans = 0;
- ans += (x.at(x.size() - 1) - '0') * 1;
- ll ax = 2;
- for (int i = 2; i <= x.size(); i++)
- {
- ans += (x.at(x.size() - i) - '0') * ax;
- ax *= 2;
- }
- cout << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment