Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. long long n, pos, now, ans;
  6.  
  7. int main()
  8. {
  9.     cin >> n;
  10.     ans = n;
  11.     for(int i = 0; i < 63; i++){
  12.         while(!((1LL << now) & n) && now <= 61){
  13.             now++;
  14.         }
  15.         if(now <= 61){
  16.             ans ^= (1LL << now);
  17.             ans |= (1LL << pos++);
  18.         }
  19.         now++;
  20.     }
  21.     cout << ans;
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement