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

建议使用的浏览器:

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

6021:MG loves string

题目描述
MG is a busy boy. And today he's burying himself in such a problem:

For a length of $N$, a random string made of lowercase letters, every time when it transforms, all the character $i$ will turn into $a[i]$.

MG states that the $a[i]$ consists of a permutation .

Now MG wants to know the expected steps the random string transforms to its own.

It's obvious that the expected steps $X$ will be a decimal number.
You should output $X*26^N mod $ $1000000007$.
输入解释
The first line is an integer $T$ which indicates the case number.($1<=T<=10$)

And as for each case, there are $1$ integer $N$ in the first line which indicate the length of random string($1<=N<=1000000000$).

Then there are $26$ lowercase letters $a[i]$ in the next line.
输出解释
As for each case, you need to output a single line.

It's obvious that the expected steps $X$ will be a decimal number.
You should output $X*26^N mod $ $1000000007$.
输入样例
2
2
abcdefghijklmnpqrstuvwxyzo
1
abcdefghijklmnopqrstuvwxyz
输出样例
5956
26
来自杭电HDUOJ的附加信息
Recommend wange2014

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

题目来源 BestCoder Round #93

源链接: HDU-6021

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

共提交 0

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