Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
96
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.  
  5. int n, N, m, mx = 1, t;
  6.  
  7. int main()
  8. {
  9. cin >> n;
  10. N = n;
  11. while (mx <= N) mx<<=1;
  12. while (n != N || !t){
  13. m = max(m, n);
  14. n<<=1;
  15. if (mx & n) n |= 1;
  16. n %= mx;
  17. t++;
  18. }
  19. cout << m;
  20. return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement