893B.md (1118B)
1 Source: https://codeforces.com/problemset/problem/893/B 2 3 B. Beautiful Divisors 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 Recently Luba learned about a special kind of numbers that she calls beautiful numbers. The number is called beautiful iff its binary representation consists of *k* + 1 consecutive ones, and then *k* consecutive zeroes. 22 23 Some examples of beautiful numbers: 24 25 * 12 (110); 26 * 1102 (610); 27 * 11110002 (12010); 28 * 1111100002 (49610). 29 30 More formally, the number is beautiful iff there exists some positive integer *k* such that the number is equal to (2*k* - 1) * (2*k* - 1). 31 32 Luba has got an integer number *n*, and she wants to find its greatest beautiful divisor. Help her to find it! 33 34 Input 35 36 The only line of input contains one number *n* (1 ≤ *n* ≤ 105) — the number Luba has got. 37 38 Output 39 40 Output one number — the greatest beautiful divisor of Luba's number. It is obvious that the answer always exists. 41 42 Examples 43 44 Input 45 46 ``` 47 3 48 ``` 49 50 Output 51 52 ``` 53 1 54 ``` 55 56 Input 57 58 ``` 59 992 60 ``` 61 62 Output 63 64 ``` 65 496 66 ```