Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <set>
  4. #include <unordered_map>
  5. #include <algorithm>
  6. #include <string>
  7. #include <unordered_set>
  8. #include <list>
  9. #include <map>
  10. #include <queue>
  11.  
  12. #define mp make_pair
  13. #define i64 long long;
  14. #define ui64 unsigned long long;
  15. using namespace std;
  16.  
  17. int main() {
  18. #ifdef _KOCH
  19. freopen("input.txt", "r", stdin);
  20. #else
  21. // freopen("search4.in", "r", stdin);
  22. // freopen("search4.out", "w", stdout);
  23. #endif
  24. int n;
  25. cin >> n;
  26.  
  27. int64_t val = 1;
  28. vector<int64_t> v(25);
  29. for (int i = 0; i < v.size(); ++i) {
  30. v[i] = val;
  31. val *= 4ll;
  32. }
  33. for (int i = 0; i < n; ++i) {
  34. int64_t a;
  35. cin >> a;
  36. int k = 24;
  37. int res = 0;
  38. while (a > 0) {
  39. int64_t x = a / v[k];
  40. if (x == 1) {
  41. res++;
  42. }
  43. if (x == 2) {
  44. res += 3;
  45. }
  46. if (x == 3) {
  47. res += 4;
  48. }
  49. a -= x*v[k];
  50. k--;
  51. }
  52. cout << res << endl;
  53. }
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement