QOJ.ac

QOJ

حد الوقت: 2.0 s حد الذاكرة: 1024 MB مجموع النقاط: 100 قابلة للهجوم ✓
الإحصائيات

生活总是充满了不确定性。例如,你可能会从题目名称中认为这是一个字符串问题,但实际上它不是。

给你一个字符串 $s$ 和一个字符 $c$。每次操作中,你随机选择一个之前未被选择过的位置 $i$,并将 $s_i$ 修改为 $c$(如果 $s_i = c$,这仍然算作一次操作)。你重复此操作,直到 $s$ 变成一个回文串时停止。你想知道所需操作次数的期望值。

特别地,如果 $s$ 在最开始就已经是一个回文串,则答案为 0。

输入格式

第一行包含一个字符串 $s$($1 \le |s| \le 250000$),保证仅由小写英文字母组成。

第二行包含一个小写英文字母 $c$。

输出格式

输出单行一个整数,表示期望值模 998244353 的结果。

样例

输入样例 1

abcab
a

输出样例 1

4

输入样例 2

abcdcbd
a

输出样例 2

177465668

输入样例 3

aba
z

输出样例 3

0

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.