#P1184A2. Heidi Learns Hashing (Medium)
Heidi Learns Hashing (Medium)
No submission language available for this problem.
Description
After learning about polynomial hashing, Heidi decided to learn about shift-xor hashing. In particular, she came across this interesting problem.
Given a bitstring find out the number of different () such that there exists for which $y = x \oplus \mbox{shift}^k(x).$
In the above, is the xor operation and $\mbox{shift}^k$ is the operation of shifting a bitstring cyclically to the right times. For example, and $\mbox{shift}^3(00010010111000) = 00000010010111$.
The first line contains an integer (), the length of the bitstring .
The second line contains the bitstring .
Output a single integer: the number of suitable values of .
Input
The first line contains an integer (), the length of the bitstring .
The second line contains the bitstring .
Output
Output a single integer: the number of suitable values of .
Samples
Note
In the first example:
- $1100\oplus \mbox{shift}^1(1100) = 1010$
- $1000\oplus \mbox{shift}^2(1000) = 1010$
- $0110\oplus \mbox{shift}^3(0110) = 1010$
There is no such that , hence the answer is .