ghost1733's blog

By ghost1733, history, 3 years ago, In English

Problem Statement: Input Format

First line contain a no. , no. of bits in binary number. Second line contain a binary number of size .

Constraints

Output Format

Output the maximum no. that this Binary no. can result using cyclic shifts into modulo ().

Sample Input 0

5 00101 Sample Output 0

20 Explanation 0

For first case maximum is if no. is rotated to give string 10100 which is 20.

Sample Input 1

6 011010 Sample Output 1

52 Explanation 1

For second case maximum is if no. is rotated to give string 110100 which is 52.

Sample Input 2

4 1100 Sample Output 2

12

I found a solution using suffix array. but is there any simple solution ?

  • Vote: I like it
  • -17
  • Vote: I do not like it

»
3 years ago, # |
  Vote: I like it +1 Vote: I do not like it