当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6877:Anti-hash Test

题目描述
It is well known that the following string $s(n)=s_0s_1 \dots s_{2^n-1}$ can challenge almost every solution that uses polynomial hashes modulo $2^{64}$:

$$
s_i=\begin{cases} a & \text{popcount(i)} \bmod 2 = 0 \\ b & \text{popcount(i)} \bmod 2 = 1 \end{cases}
$$
where $\text{popcount}(i)$ means the number of ones in binary representation of number $i$.

Given a string $u$ and an integer $n$, find the number of occurrences of $u$ in string $s(n)$ and the number of distinct strings $v$ which have the same number of occurrences in string $s(n)$. As both the numbers may be very large, you are only asked to calculate it modulo $10^9 + 7$.
输入解释
There are multiple test cases. The first line of input contains an integer $T$, indicating the number of test cases. For each test case:

The first line contains an integer $n$ ($1 \le n \le 10^{18}$).

The second line contains a string $u$ ($1 \le |u| \le \min(10^6, 2^n)$) consisting only of letters `a' and `b'.

It is guaranteed that the size of the input file does not exceed 20M.
输出解释
For each test cases, if the string $u$ does not appear in string $s(n)$, you should simply output $-1$. Otherwise, output two integers denoting the the number of occurrences of $u$ in string $s(n)$ modulo $10^9 + 7$ and the number of distinct strings $v$ which have the same number of occurrences in string $s(n)$ modulo $10^9 + 7$.
输入样例
4
10
a
10
abba
5
abbabaabbaababbabaababbaabbabaab
20
ababab
输出样例
512 2
171 4
1 344
-1
来自杭电HDUOJ的附加信息
Recommend IceyWang

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6877

最后修改于 2020-10-25T23:35:10+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 262144/262144K(Java/Others)