Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define mx 1000008
- int a[mx+3];
- int main()
- {
- int n;
- while(cin>>n && n!=0){
- int cnt=0;
- int m=n;
- while(n>1){
- n=n/2;
- cnt++;
- }
- int po=2;
- for(int i=1;i<cnt;i++){
- po=po*2;
- }
- int ans=2*(m-po);
- if(ans==0 || m==1) cout<<m<<endl;
- else
- cout<<ans<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement