Problem 3044 --Acesrc and String Theory

3044: Acesrc and String Theory

"
Time Limit $6$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $3$ 正确数量 $2$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
Acesrc is a famous string theorist at Nanjing University second to none. He insists that we should always say an important thing kktimes. He also believes that every string that can be obtained by concatenating kk copies of some nonempty string is splendid. So, he always teaches newcomers, ``String theory problems are important! String theory problems are important! ... String theory problems are important!" 

Today, he wants to examine whether the newcomers remember his instruction. He presents a string consisting of lower case letters and asks them the number of splendid substrings of the presented string. No one can solve this problem, and they will be scolded for hours. Can you help them solve this problem? 

Note that equal splendid substrings occurred in different positions should be counted separately.
The first line of input consists of a single integer TT (1≤T≤10)(1≤T≤10), denoting the number of test cases. Each test case starts with a single line of an integer kk (1≤k≤20)(1≤k≤20). The second line of a test case is a string SS consisting of lower case letters only, the length of which is between 11 and 3×1053×105 inclusive. The sum of the lengths of strings in all test cases never exceeds 106106.
For each test case, print the answer as a single integer in a single line.
3
2
aabb
2
abababab
3
abc
2
6
0

推荐代码 查看3044 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$1513 $ms] 淡意的温柔 591141 2020-06-06 08:41:17
内存最少[$18688 $KB] 淡意的温柔 591141 2020-06-06 08:41:17
第一AC intLSY 479430 2019-10-04 22:17:15
第一挑战 intLSY 479430 2019-10-04 22:17:15

赛题来源/所属竞赛 2019 Multi-University Training Contest 8 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛