SHARE
TWEET

Untitled

a guest Dec 9th, 2019 197 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  
  3. Sviatoslav Bidzilia 2019
  4. CF: anakib1
  5.  
  6. */
  7.  
  8. #include <iostream>
  9. #include <cmath>
  10. #include <algorithm>
  11. #include <stdio.h>
  12. #include <cstring>
  13. #include <string>
  14. #include <cstdlib>
  15. #include <vector>
  16. #include <bitset>
  17. #include <map>
  18. #include <chrono>
  19. #include <unordered_set>
  20. #include <unordered_map>
  21. #include <numeric>
  22. #include <queue>
  23. #include <ctime>
  24. #include <stack>
  25. #include <set>
  26. #include <list>
  27. #include <deque>
  28. #include <iomanip>
  29. #include <sstream>
  30. #include <fstream>
  31. #include <stdarg.h>
  32. #include <utility>
  33.  
  34. using namespace std;
  35.  
  36. #define pb push_back
  37. #define mp make_pair
  38. #define ll long long
  39. #define ull unisgned long long
  40. #define ld long double
  41. #define all(a) a.begin(), a.end()
  42. #define SORT(a) sort(all(a))
  43. #define pii pair<int, int>
  44. #define tii triple<int, int, int>
  45. #define e 1e-7
  46. #define PI acos(-1)
  47. #define inf 1e17
  48. #define vi vector<int>
  49. #define F first
  50. #define S second
  51. #define rng(x) for(int _ = 0; _ < (x); _++)
  52. #define rngi(i, x) for(int i = 0; i < (x); i++)
  53. #define rngsi(s, i, x) for(int i = (s); i <(x); i++)
  54. #define int long long
  55.  
  56. template<typename A, typename B, typename C>
  57. struct triple
  58. {
  59.     A X;
  60.     B Y;
  61.     C Z;
  62.     triple(A a = 0, B b = 0, C c = 0) :X(a), Y(b), Z(c) {}
  63. };
  64. template<typename A, typename B, typename C>
  65. triple<A, B, C> make_triple(A a = 0, B b = 0, C c = 0)
  66. {
  67.     return triple<A, B, C>(a, b, c);
  68. }
  69. template<typename A, typename B, typename C>
  70. bool operator<(const triple<A, B, C>& a, const triple<A, B, C>& b)
  71. {
  72.     if (a.X != b.X)
  73.         return a.X < b.X;
  74.     if (a.Y != b.Y)
  75.         return a.Y < b.Y;
  76.     return a.Z < b.Z;
  77. }
  78. template<typename T, typename SS>
  79. ostream& operator<<(ostream& ofs, const pair<T, SS>& p)
  80. {
  81.     ofs << "( " << p.F << " , " << p.S << " )";
  82.     return ofs;
  83. }
  84. template<typename T>
  85. void print(T a)
  86. {
  87.     for (auto i : a)
  88.         cout << i << ' ';
  89.     cout << '\n';
  90. }
  91. template<typename T>
  92. T max(T a, T b, T c)
  93. {
  94.     return max(a, max(b, c));
  95. }
  96. template<typename T>
  97. T min(T a, T b, T c)
  98. {
  99.     return min(a, min(b, c));
  100. }
  101. struct custom_hash
  102. {
  103.     static uint64_t splitmix64(uint64_t x)
  104.     {
  105.         x += 0x9e3779b97f4a7c15;
  106.         x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
  107.         x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
  108.         return x ^ (x >> 31);
  109.     }
  110.  
  111.     size_t operator()(uint64_t x) const
  112.     {
  113.         static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
  114.         return splitmix64(x + FIXED_RANDOM);
  115.     }
  116. };
  117. #define A0(x) x,
  118. #define A1(x) A0(x) A0(x + 1) A0(x + 3) A0(x + 4)
  119. #define A2(x) A1(x) A1(x + 1) A1(x + 3) A1(x + 4)
  120. #define A3(x) A2(x) A2(x + 1) A2(x + 3) A2(x + 4)
  121. #define A4(x) A3(x) A3(x + 1) A3(x + 3) A3(x + 4)
  122. #define A5(x) A4(x) A4(x + 1) A4(x + 3) A4(x + 4)
  123. #define A6(x) A5(x) A5(x + 1) A5(x + 3) A5(x + 4)
  124. #define A7(x) A6(x) A6(x + 1) A6(x + 3) A6(x + 4)
  125. string do4(int x)
  126. {
  127.     vi a;
  128.     while (x)
  129.     {
  130.         a.pb(x % 4);
  131.         x /= 4;
  132.     }
  133.     reverse(all(a));
  134.     string s = "" ;
  135.     for (auto i : a)
  136.         s.pb('0' + i);
  137.     return s;
  138. }
  139. signed main()
  140. {
  141.     //freopen(".in", "r", stdin);
  142.     //freopen(".out", "w", stdout);
  143.     srand(time(NULL));
  144.     cin.tie(0);
  145.     cout.tie(0);
  146.     ios_base::sync_with_stdio(false);
  147.     //vi a({ A3(0) });
  148.     int n;
  149.     cin >> n;
  150.     rng(n)
  151.     {
  152.         int x;
  153.         cin >> x;
  154.         vi b;
  155.         while (x)
  156.         {
  157.             b.pb(x % 4);
  158.             x /= 4;
  159.         }
  160.         reverse(all(b));
  161.         int z = 0;
  162.         for (auto i : b)
  163.             if (i < 2)
  164.                 z += i;
  165.             else
  166.                 z += 1 + i;
  167.         cout << z << '\n';
  168.     }
  169. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top