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

建议使用的浏览器:

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

BZOJ3846:ZCC loves words

题目描述
ZCC’s English is so poor that his teacher GPS forced him to memorize words. In order to examine ZCC, GPS created a software. This software works as follow. A user inputs a string S which only consists of uppercase into this software, then the software calculates the score which string S has by using its strange methods.Initially the software stores n different words and the initial score is 1. The length of S is L. The chars of string S is labeled from 1 to L(left to right), and S[i] represent the i-th char of S. 
// Prime[k] means the k-th prime number, such as Prime[1]=2, Prime[2]=3 ,Prime[8]=19.
Input >> S
Score = 1
For i = 1 to L do
For k=1 to n do
If S[j..i] equals to Word[k]
Score = Score * Prime[k] * ( i * 2 - j + 1 )
Output << Score
The pseudocode above shows when input S what score we can get.
If n=2,L=3,Word[1]=”AB”,Word[2]=”BB” then 
Score[ABB] = 1 * ( 2 * 2 - 1 + 1 ) * Prime[1] * ( 3 * 2 - 2 + 1 ) * Prime[2],
Score[CBA] = 1,
Score[CAB] = 1 * ( 3 * 2 - 2 + 1 ) * Prime[1];
ZCC has found a BUG which can help him to input strings into the software as much as he can. And the score he gets in the end is the sum of the score he gets in each input.ZCC wants to know the score he will get in the end, if he input all the different strings into the software. That is to say if the length of string is L, he can input 26^L strings in all. The answer can be very large, so what ZCC actually want is the ans Mod 5047621.

输入解释
The input contains several test cases.Two integers N(1≤N≤40),L(1≤L≤10^17) will exist in the first line of each input, indicating the number of words and the length of each S you can input to the software. Next n line contains n words, the i-th line means Word[i].Let Len[i] be the length of Word[i], and Len[1]+Len[2]…+Len[n]<=40.

输出解释
For each test case, output the score Mod 5047621.

输入样例
2 3
AB
BB
4 1
A
B
C
D
1 2
A
3 3
ZZ
ZZA
ZZZ
输出样例
Case #1: 18894
Case #2: 56
Case #3: 899
Case #4: 20511
提示

For the second test case, all the 4 words can be got. So score is (1*2-1+1)*(2+3+5+7)+22.

5047621=179*173*163


BZPRO Powered by Remmina.
Github Repository
来自acmore.cc的附加信息
bzoj_id 3846
import_source_sha256 2544efc1f3cde2cefbb71d07e0eef80f06ca9ed122b03e3698b69ef8c6f983f8
bzoj_checker_pending False

该题目包含在题集 大视野(八中)OJ 中

题目来源 BZOJ 3846

源链接: LOCAL-BZOJ3846

共提交 0 次

通过率 --%
时间上限 内存上限
5000 MS 32 MB