当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7055:Yiwen with Sqc

题目描述
Recently, Yiwen is learning Assembly Language.

Since Yiwen is a genius in computer science, he proposed an extremely valuable technique called Basic Instruction Technology. Using this kind of technique, Yiwen can create numerous different instruction. Some of these instruction can be used to calculate some special eigenvalue of a string, such as $sqc$.

For a string $s$, let $s_i$ be the $i^{th}$ character of it.

Instruction sqc has 4 operands $s$, $l$, $r$ and $c$, where $s$ is a string, $1 \leq l \leq r \leq n$, $c$ is a character represented by ASCII value. $sqc(s,l,r,c)$ returns the number of character $c$ in substring $s_l \cdots s_r$.

Yiwen wants you to calculate following expression for the given string $s$: $$\sum_{c=97}^{122}\sum_{i=1}^{n}\sum_{j=i}^{n} sqc(s,i,j,c)^2$$

Note that the ASCII value of 'a' is $97$ and the ASCII value of 'z' is $122$.

The answer will probably be very huge, so just calculate the answer modulo $998244353$.
输入解释
The input consists of multiple test cases.

The first line contains an integer $T$ ($1 \leq T \leq 100$) -- the number of test cases.

For each test case, the only line contains a string $s$ ($|s| \leq 10^5$) consists of lowercase English letters.

It is guaranteed that the sum of $|s|$ over all test cases does not excceed $5 \times 10^6$.
输出解释
For each test case, output your answer modulo $998244353$ in a single line.
输入样例
5
ababa
a
abcdefga
afidhehfhd
ggggggggggg
输出样例
57
1
122
328
1716

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7055

最后修改于 2021-10-23T19:11:14+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 524288/524288K(Java/Others)