Universal Cup Judging System

Universal Cup

Time Limit: 2.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓
Statistics

生活總是充滿了不確定性。例如,你可能會從題目名稱中認為這是一個字串問題,但實際上它不是。

給你一個字串 $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.