CF1184A2.Heidi Learns Hashing (Medium)
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
After learning about polynomial hashing, Heidi decided to learn about shift-xor hashing. In particular, she came across this interesting problem.
Given a bitstring y∈0,1n find out the number of different k (0≤k<n) such that there exists x∈0,1n 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 k times. For example, 001⊕111=110 and \mbox{shift}^3(00010010111000) = 00000010010111.
学习了多项式哈希之后,Heidi 决定学习移位-异或(shift-xor)哈希。特别是,她遇到了这个有趣的问题:
给定一个长度为 n 的比特串 y∈{0,1}n,求满足如下条件的不同 k(其中 0≤k<n)的个数:存在某个 x∈{0,1}n,使得 y = x \oplus \mbox{shift}^k(x)。
其中,⊕ 表示按位异或(XOR)运算,\mbox{shift}^k 表示将一个比特串循环右移 k 位的操作。例如,001⊕111=110,且 \mbox{shift}^3(00010010111000) = 00000010010111。
输入格式
The first line contains an integer n (1≤n≤2⋅105), the length of the bitstring y.
The second line contains the bitstring y.
第一行包含一个整数 n(1≤n≤2⋅105),表示位串 y 的长度。
第二行包含位串 y。
输出格式
Output a single integer: the number of suitable values of k.
输出一个整数:满足条件的 k 的个数。
输入输出样例
输入#1
4 1010
输出#1
3
说明/提示
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 x such that x⊕x=1010, hence the answer is 3.
在第一个例子中:
- 1100\oplus \mbox{shift}^1(1100) = 1010
- 1000\oplus \mbox{shift}^2(1000) = 1010
- 0110\oplus \mbox{shift}^3(0110) = 1010
不存在满足 x⊕x=1010 的 x,因此答案为 3。
输入解题思路,AI测评打分。不知道怎么写?