8605: Mi Re Do Si La? So Fa!

内存限制:256 MB 时间限制:8 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

XiYue likes watching the white moon. Under the moonlight, each star has its own beauty. The same thing holds for strings.

For a string s with length n, p is a period of n if it satisfies p∣n and si=si+p,∀0≤i<n−p.

For a string s, define its beauty f(s) as the sum of its periods.

For example, aaaa has periods 1,2,4, so it has beauty f(aaaa)=7, aba has only one period 3, so f(aba)=3.
Now, given a string s consisting of lowercase English letters, you need to calculate 0≤l≤r<∣s∣f(sl,r), i.e., the sum of beauty over all substrings of s.

输入格式

The first line contains an integer T, denoting the number of test cases. (T≥1).
For each test case, the first line contains a string consisting of lowercase English letters, denoting s.
It is guaranteed that the sum of |s| over all test cases won't exceed 106.

输出格式


For each test case, output an integer in a single line, denoting the answer.

输入样例 复制

3
crazythursdaykfcvmefifty
mmrooe
qaqqaq

输出样例 复制

2600
58
60