Cycle shifts

Lets write the decimal integer N in binary notation and create all its left cycle shifts where first digit of the number goes to the end.
For example, if N=11, than it will be 1011 in binary notation, cycle shifts are 0111, 1110, 1101, 1011. The maximal value M among all received numbers in such way will have the number 11102=1410.
For the number N find the maximal value of M.
Specifications
Input
One number N (1 ≤ N ≤ 2·109).
Output
One number M.
Problem information
Time Limit: 1 secondsMemory Limit: 64 MB
Balls for the passed test: 10
Complexity: 15% 538/636
Classes: Number theory
My result: 1/1
Example
Example input11 |
Example output14 |
| ← New-year presents | Problems | Product → |
