QOJ.ac

QOJ

Limite de temps : 16 s Limite de mémoire : 256 MB Points totaux : 100

#6891. 字符串与 GCD

Statistiques

给定一个长度为 $n$ 的仅包含小写字母的字符串。 $S[l : r]$ 表示从第 $l$ 个字符到第 $r$ 个字符连接而成的子串。 $B$ 是一个布尔表达式,艾弗森括号定义为: $$[B]= \begin{cases} 1, & \text{如果 } B \text{ 为真} \\ 0, & \text{其他情况} \end{cases}$$ $\gcd(i, j)$ 表示 $i$ 和 $j$ 的最大公约数。 我们定义 $f(i) = \sum_{j=1}^{i-1} [S[1 : j] == S[i - j + 1 : i]] \times \gcd(i, j)$。 现在要求 $\prod_{i=1}^{n} (f(i) + 1) \pmod{998\,244\,353}$ 的值。

输入格式

第一行输入一个正整数 $T(T \le 10)$,表示测试用例的数量。 对于每个测试用例,输入一个长度不超过 $10^6$ 的小写字母字符串 $S$。

输出格式

对于每个测试用例,输出一行包含一个正整数,表示答案。

样例

样例输入 1

5
aaaaa
aabaab
abcdefghi
abaabaaba
abbabbabb

样例输出 1

150
48
1
3840
1344

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.