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

建议使用的浏览器:

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

6761:Minimum Index

题目描述
Let s=$s_1$ $s_2$$ \cdots $$s_n$ be a string of length n. For any integer k between 1 to n, the $k^{th}$ suffix of s is defined as $s_k$ $s_{k+1}$$ \cdots $$s_n$. For example, the $4^{th}$ suffix of “contest” is “test” and the $1^{st}$ suffix of “suffix” is “suffix” itself.

One can consider lexicographically smallest suffix of s. Let the $k^{th}$ suffix is lexicographically minimum among all suffixes of s. Conveniently, let’s call such k minimum index of s. Given a string t=$t_1$ $t_2 \cdots t_n$, your task is to calculate the sum of (minimum index of $t_1$ $t_2 \cdots t_i$)$ \cdot 1112^{i-1}$ over all i=1,2,3,$ \cdots $,n. This value may be too large, you are only required to print it modulo $10^9$+7.
输入解释
The first line of the input contains a single integer T (1≤T≤10 000), the number of test cases. Each of the next T lines contains a non-empty string with at most $10^6$ lowercase English letters. The total length of the input string over all test cases doesn’t exceed $2 \cdot 10^7$.
输出解释
For each test case, you should print the answer in a single line.
输入样例
1
aab
输出样例
1238769

提示
The minimum index of “a”, “aa”, “aab” is 1, 2, 1 respectively. So the answer is (1+2∙1112+1112^2) mod (10^9+7)=1238769.
来自杭电HDUOJ的附加信息
Recommend liuyiding

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

源链接: HDU-6761

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

共提交 0

通过率 --%
时间上限 内存上限
3000/1500MS(Java/Others) 524288/524288K(Java/Others)