string string string
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 337 Accepted Submission(s): 75
Problem Description
Uncle Mao is a wonderful ACMER. One day he met an easy problem, but Uncle Mao was so lazy that he left the problem to you. I hope you can give him a solution.
Given a string s, we define a substring that happens exactly
k times as an important string, and you need to find out how many substrings which are important strings.
Input
The first line contains an integer
T (
T≤100) implying the number of test cases.
For each test case, there are two lines:
the first line contains an integer
k (
k≥1) which is described above;
the second line contain a string
s (
length(s)≤105).
It's guaranteed that
∑length(s)≤2∗106.
Output
For each test case, print the number of the important substrings in a line.
Sample Input
2 2 abcabc 3 abcabcabcabc
Sample Output
Source
2017 ACM/ICPC Asia Regional Shenyang Online
Recommend
liuyiding | We have carefully selected several similar problems for you: 6205 6204 6203 6202 6201
后缀数组预处理出高度数组H,然后 用区间最小值-两端的最大值统计即可
#include