Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int n, N, m, mx = 1, t;
- int main()
- {
- cin >> n;
- N = n;
- while (mx <= N) mx<<=1;
- while (n != N || !t){
- m = max(m, n);
- n<<=1;
- if (mx & n) n |= 1;
- n %= mx;
- t++;
- }
- cout << m;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement