Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool test(int n){
- while(n%2==0){
- n/=2;
- }
- if(n==1)
- return 1;
- else
- return 0;
- }
- int main()
- {int N;
- cin>>N;
- int x=N;
- while(x){
- if(test(x)==1)
- {cout<<2*(N-x)+1;
- break;}
- else
- x--;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement