Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. bool test(int n){
  5. while(n%2==0){
  6. n/=2;
  7. }
  8. if(n==1)
  9. return 1;
  10. else
  11. return 0;
  12. }
  13. int main()
  14. {int N;
  15. cin>>N;
  16. int x=N;
  17. while(x){
  18. if(test(x)==1)
  19. {cout<<2*(N-x)+1;
  20. break;}
  21. else
  22. x--;
  23. }
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement