Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- long long n, pos, now, ans;
- int main()
- {
- cin >> n;
- ans = n;
- for(int i = 0; i < 63; i++){
- while(!((1LL << now) & n) && now <= 61){
- now++;
- }
- if(now <= 61){
- ans ^= (1LL << now);
- ans |= (1LL << pos++);
- }
- now++;
- }
- cout << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement