Advertisement
Kali_prasad

swap bits qk8

Mar 22nd, 2022
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #pragma GCC optimize ("O3")
  2. #pragma GCC target ("sse4")
  3.  
  4. #include <bits/stdc++.h>
  5. using namespace std;
  6.  
  7. typedef long long ll;
  8. typedef pair<int, int> pii;
  9. typedef pair<string,int> psi;
  10. typedef vector<int> vi;
  11. typedef vector<vector<int>> vvi;
  12.  
  13. #define FOR(i, a, b) for (auto i=a; i<=(b); i++)
  14. #define FORd(i,b,a) for (int i =b; i >= a; i--)
  15. #define sz(x) (int)(x).size()
  16. #define mp make_pair
  17. #define pb push_back
  18. #define f first
  19. #define s second
  20. #define ins insert
  21.  
  22. const int MOD = 1000000007;
  23. //type functions here
  24. ll swapbits(ll a)
  25. {
  26.     return ((a&0x555555)<<1|(a&0xAAAAAA)>>1);
  27. }
  28.  
  29.  
  30. int main() {
  31.     int tc;
  32.     cin>>tc;
  33.     FOR(i,0,tc-1){
  34.     ll a;
  35.     cin>>a;
  36.     cout<<swapbits(a)<<endl;
  37.     }
  38.     return 0;
  39. }
  40.  
  41.  
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement