题号:NC241128
时间限制:C/C++/Rust/Pascal 8秒,其他语言16秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld
题目描述
XiYue likes watching the white moon. Under the moonlight, each star has its own beauty. The same thing holds for strings.
For a string

with length

,

is a
period of

if it satisfies

and

.
For a string

, define its
beauty )
as the sum of its periods.
For example,

has periods

, so it has beauty
%20%3D%207)
,

has only one period

, so
%20%3D%203)
.
Now, given a string
consisting of lowercase English letters, you need to calculate
, i.e., the sum of beauty over all substrings of
.
输入描述:
The first line contains an integer
, denoting the number of test cases.
.
For each test case, the first line contains a string consisting of lowercase English letters, denoting
.
It is guaranteed that the sum of
over all test cases won't exceed
.
输出描述:
For each test case, output an integer in a single line, denoting the answer.
示例1
输入
复制
3
crazythursdaykfcvmefifty
mmrooe
qaqqaq