SHARE
TWEET

Untitled

a guest Oct 21st, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
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
 
Top