Logo
(追記) (追記ここまで)

23549번 - String Theory 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 (추가 시간 없음) 512 MB233250.000%

문제

Acesrc is a famous string theorist at Nanjing University second to none. He insists that we should always say an important thing $k$ times. He also believes that every string that can be obtained by concatenating $k$ 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 $T$ $(1 \leq T \leq 10),ドル denoting the number of test cases. Each test case starts with a single line of an integer $k$ $(1 \leq k \leq 20)$. The second line of a test case is a string $S$ consisting of lower case letters only, the length of which is between 1ドル$ and 3ドル \times 10^5$ inclusive. The sum of the lengths of strings in all test cases never exceeds 10ドル^6$.

출력

For each test case, print the answer as a single integer in a single line.

제한

예제 입력 1

3
2
aabb
2
abababab
3
abc

예제 출력 1

2
6
0

힌트

출처

Contest > Open Cup > 2019/2020 Season > Stage 17: Grand Prix of Nanjing (by Legilimens+Coffee Chicken) D번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /