QOJ.ac

QOJ

时间限制: 2.0 s 内存限制: 1024 MB 总分: 100 可 Hack ✓

#9747. 字符串复制

统计

Little H 最初有一个由小写字母组成的字符串 $s$。

字符串的“魅力值”定义为本质不同的子串数量。例如,aaa 只有 3 个本质不同的子串:a, aa, aaa,而 aabb 有 8 个本质不同的子串:a, aa, b, bb, ab, aab, abb, aabb。

他认为初始字符串 $s$ 的魅力值太低了,于是他将 $s$ 复制 $m$ 次并拼接在一起,试图得到一个魅力值更高的字符串。

然而,在他完成复制后,他发现自己无法准确计算其魅力值。请帮他计算这个拼接后的字符串的魅力值。由于答案可能很大,你需要输出魅力值对 998244353 取模的结果。

输入格式

第一行包含两个整数 $n, m$ ($1 \le n \le 3 \times 10^5, 1 \le m \le 10^9$),分别表示字符串 $s$ 的长度和复制次数。

第二行包含一个由小写字母组成的字符串 $s$。

输出格式

输出一个整数,表示魅力值对 998244353 取模的结果。

样例

样例输入 1

6 2
mantle

样例输出 1

57

样例输入 2

12 1919810
ifamjlifamjl

样例输出 2

138226305

样例输入 3

13 935330878
aabbbbababbaa

样例输出 3

348310505

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.