Advertisement
ke_timofeeva7

коровы шифруют

Jul 2nd, 2021
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.76 KB | None | 0 0
  1. /*
  2. ──────▄▌▐▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▌
  3. ───▄▄██▌█░ВЕЗЕМ▄▀▀▀▄░ГУСЕЙ░░░░░░░
  4. ───████▌█▄███▀░◐░▄▀▀▀▄░░(РАБОТЯГИ)░
  5. ──██░░█▌█░░▄███▀░◐░░▄▀▀▀▄░░░░░░░
  6. ─██░░░█▌█░░░░▐░▄▀▀▀▌░░░░◐░▀███▄░
  7. ███████▌█▄███▀░◐░░░▌░░░░░▐░░░░░░
  8. ░██████▌█░░░░▌░░░░░▌░░░░░▐░░░░░░
  9. ███████▌█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▌
  10. ▀(@)▀▀▀▀▀▀▀(@)(@)▀▀▀▀▀▀▀▀▀▀▀▀▀(@)▀(@
  11. */
  12.  
  13. /*
  14. ВЗГЛЯНИ ░ВОКРУГ,
  15. ░ОГЛЯНИСЬ░НАЗАД!
  16. ░ГУСИ░▄▀▀▀▄░С░ТОБОЮ░░░
  17. ░░░░▀░░░◐░▀███▄░░░░
  18. ░░░░▌░░░░░▐░░░░░░░
  19. ░░░░▐░░░░░▐░░░░░░░
  20. ░░░░▌░░░░░▐▄▄░░░░░
  21. ░░░░▌░░░░▄▀▒▒▀▀▀▀▄
  22. ░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
  23. ░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
  24. ░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
  25. ░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
  26. ░СВЯЗАТЬСЯ░░▌▌░▌▌░░░░░
  27. ░░░ХОТЯТ░░░░▌▌░▌▌░░░░░
  28. ░░░░░░░░░░░▄▄▌▌▄▌▌░░
  29. */
  30.  
  31. /*
  32. ЗАПУСКАЕМ
  33. ░░◐░░◐░░░ХАЧИКУДЖИ░░░░░░░░░
  34. ░░▐░░▌░░░░░░▄▄▄▄░░░░░░░░░░░
  35. ░░▐░░▌░░░▄▀▀░▄▄▄▀▀▄░░░░░░░░
  36. ░░▐▄▄▌░▐▀░▐▀▀░▄░▀▌░▀▌░░░░░░
  37. ░▐░░░░▀▐░▐░░░▄▄▌░░▌░▀▌░░░░░
  38. ░░▀▌░░░▐▄░▀▀▀░░░▄▄▌░▄▌░░░░░
  39. ░░░░▀▄░░░▐▄▄▄▀▀▀░░▄▀░░░░░░░
  40. ░░░░░░▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀░░░░░
  41. */
  42.  
  43. #include <iostream>
  44. #include <string>
  45. #include <sstream>
  46. #include <cmath>
  47. #include <algorithm>
  48. #include <memory.h>
  49. #include <stdio.h>
  50. #include <stack>
  51. #include <deque>
  52. #include <queue>
  53. #include <vector>
  54. #include <set>
  55. #include <iterator>
  56. #include <map>
  57. #include <iomanip>
  58. #include <unordered_set>
  59. #define int long long
  60. #define sp system("pause")
  61. #define pb push_back
  62. #define double long double
  63. #define endl "\n"
  64. #define un unsigned
  65. #define INF 1000000009
  66. #define pii pair<int, int>
  67. #define all(v) v.begin(), v.end()
  68. #define ll long long
  69. using namespace std;
  70.  
  71. istream& operator >> (istream& in, vector<int>& a)
  72. {
  73.     for (int i = 0; i < a.size(); i++)
  74.     {
  75.         in >> a[i];
  76.     }
  77.  
  78.     return in;
  79. }
  80.  
  81. ostream& operator << (ostream& out, vector<int>& a)
  82. {
  83.     for (int i = 0; i < a.size(); i++)
  84.     {
  85.         out << a[i] << " ";
  86.     }
  87.  
  88.     return out;
  89. }
  90.  
  91. signed main()
  92. {
  93.     ios_base::sync_with_stdio(false);
  94.     cin.tie(0);
  95.     cout.tie(0);
  96.  
  97.     string s;
  98.     cin >> s;
  99.  
  100.     int n;
  101.     cin >> n;
  102.  
  103.     int k = n;
  104.     int a = 0;
  105.  
  106.     vector<int> st(64);
  107.  
  108.     st[0] = s.size();
  109.  
  110.     for (int i = 1; i < 64; i++)
  111.     {
  112.         st[i] = st[i - 1] * 2;
  113.     }
  114.  
  115.  
  116.     while (k > s.size())
  117.     {
  118.         int a = lower_bound(all(st), k) - st.begin();
  119.  
  120.         a = st[a];
  121.  
  122.         if (k < a / 2)
  123.         {
  124.             k /= 2;
  125.         }
  126.         else
  127.         {
  128.             k = k - a / 2 - 1;
  129.         }
  130.  
  131.         if (k == 0)
  132.         {
  133.             k = a / 2;
  134.         }
  135.     }
  136.  
  137.     cout << s[k - 1];
  138.  
  139.     return 0;
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement