No.2131 Concon Substrings (COuNt Version)
タグ : / 解いたユーザー数 129
作問者 : 👑
taiga0629kyopro
Problem Statement
For a string $T$ consisting of lowercase English letters, define $f(T)$ as the maximum non-negative integer $i$ satisfying the following condition.
There exists a not necessarily contiguous subsequence of $T$ that contains the string
conas a contiguous substring exactly $i$ times.
There are $26^N$ possible strings $S$ of length $N$ consisting of lowercase English letters. Find $f(S)$ for all of them and output the sum modulo $998244353$.
Constraints
- $3 \leq N \leq 3000$
- $N$ is an integer.
Input
The input is given from standard input in the following format.
$N$
Output
Output the sum of $f(S)$ modulo $998244353$.
Sample
Sample 1
Input
3
Output
1
Among strings of length $3$, considering their not necessarily contiguous subsequences, the strings that can contain $1$ occurrence of con as a contiguous substring number only $1$, namely con, and none can contain $2$ or more. Thus, the answer is $1$.
Sample 2
Input
4
Output
101
Among strings of length $4$, considering their not necessarily contiguous subsequences, the strings that can contain $1$ occurrence of con as a contiguous substring include, for example, corn and cron, and there are $101$ such strings. None can contain $2$ or more, so the answer is $101$.
Sample 3
Input
6
Output
322027
For strings of length $6$, considering their not necessarily contiguous subsequences:
- There are $322025$ strings that can contain $1$ occurrence of
conas a contiguous substring, such ascouponandcarbon. - There is only $1$ string that can contain $2$ occurrences of
conas a contiguous substring, namelyconcon. - There are no strings that can contain $3$ or more occurrences of
conas a contiguous substring.
Therefore, the answer is $1 \times 322025 + 2 \times 1 = 322027$.
Sample 4
Input
2021
Output
777297048
Output the sum of $f(S)$ modulo $998244353$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。