T3000

Untitled

Jun 25th, 2022
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. using ll = long long;
  5. using ld = long double;
  6.  
  7. int main()
  8. {
  9.  
  10.     vector<string> z1;
  11.     // base 2 palindrom generator :
  12.     string x = "1";
  13.     z1.push_back(x);
  14.     for (int i = 0; i < 50000; i++)
  15.     {
  16.         x = x + '1';
  17.         string aux = x;
  18.         vector<string> ax;
  19.         ll x1 = 1, x2 = aux.size() - 2;
  20.         while (aux.at(aux.size() / 2) != 0 && x1 <= x2)
  21.         {
  22.             aux.at(x1) = '0';
  23.             aux.at(x2) = '0';
  24.             ax.push_back(aux);
  25.             x1 += 1;
  26.             x2 -= 1;
  27.             i += 1;
  28.             if (i == 49999)
  29.             {
  30.                 break;
  31.             }
  32.         }
  33.         reverse(ax.begin(), ax.end());
  34.         z1.insert(z1.end(), ax.begin(), ax.end());
  35.         z1.push_back(x);
  36.     }
  37.     ll n;
  38.     cin >> n;
  39.     x = z1.at(n - 1);
  40.     ll ans = 0;
  41.     ans += (x.at(x.size() - 1) - '0') * 1;
  42.     ll ax = 2;
  43.     for (int i = 2; i <= x.size(); i++)
  44.     {
  45.         ans += (x.at(x.size() - i) - '0') * ax;
  46.         ax *= 2;
  47.     }
  48.     cout << ans;
  49.  
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment