Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define mx 1000008
  4. int a[mx+3];
  5.  
  6. int main()
  7. {
  8.     int n;
  9.     while(cin>>n && n!=0){
  10.         int cnt=0;
  11.         int m=n;
  12.         while(n>1){
  13.             n=n/2;
  14.             cnt++;
  15.         }
  16.         int po=2;
  17.         for(int i=1;i<cnt;i++){
  18.             po=po*2;
  19.         }
  20.         int ans=2*(m-po);
  21.         if(ans==0 || m==1) cout<<m<<endl;
  22.         else
  23.         cout<<ans<<endl;
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement