F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

String and GCD

Time Limit: 32000/16000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 424    Accepted Submission(s): 98


Problem Description
There is a string of length $n$ which only contains lowercase letters.

$S[l:r]$ represents the string concatenated from the $l$ -th character to the $r$ -th character.

$B$ is a boolean expression,the Iverson brackets

$$[B]=\left\\\{\begin{aligned}&1,if\ B\ is\ true \\\\&0,otherwise\end{aligned}\right.$$

$\gcd(i,j)$ is the greatest common divisor of $i$ and $j$.

We define $f(i)=\displaystyle \sum_{j=1}^{i-1} [S[1:j]==S[i-j+1:i]]\times \gcd(i,j)$.

Now ask for the value of $\displaystyle \prod _{i=1}^n(f(i)+1)$ modulo $998\ 244\ 353$.
 

Input
The first line of input is a positive integer $T(T\leq 10)$ representing the number of test cases.

For each case,input a string $S$ of lowercase letters, no longer than $10^6$.
 

Output
For each case, output a line with a positive integer representing the answer.


Notes:
In this problem, you may need more stack space to pass this problem.
We suggest you to add the following code into your main function if you use C++.

```
int main() {
int size(512<<20); // 512M
__asm__ ( "movq %0, %%rsp\n"::"r"((char*)malloc(size)+size));
// YOUR CODE
...
exit(0);
}

```

And if you use the code above please $\textbf{DON'T forget to add exit(0)}$; in the end of your main function, otherwise your code may get RE.
 

Sample Input
5 aaaaa aabaab abcdefghi abaabaaba abbabbabb
 

Sample Output
150 48 1 3840 1344
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 08:46:18, Gzip enabled