102345: [AtCoder]ABC234 F - Reordering
Description
Score : $500$ points
Problem Statement
Given is a string $S$. How many different strings can be obtained as a permutation of a non-empty, not necessarily contiguous subsequence of $S$?
Since the count can be enormous, print it modulo $998244353$.
Constraints
- $S$ is a string of length $1$ and $5000$ (inclusive) consisting of lowercase English letters.
Input
Input is given from Standard Input in the following format:
$S$
Output
Print the number of different strings that can be obtained as a permutation of a subsequence of $S$, modulo $998244353$.
Sample Input 1
aab
Sample Output 1
8
There are $8$ different strings that can be obtained as a permutation of a subsequence of $S$: a
, b
, aa
, ab
, ba
, aab
, aba
, baa
.
Sample Input 2
aaa
Sample Output 2
3
Sample Input 3
abcdefghijklmnopqrstuvwxyz
Sample Output 3
149621752
Be sure to print the count modulo $998244353$.
Input
题意翻译
给定一个仅有小写字母的字符串 $S$,你需要求出对于 $S$ 的所有**非空子序列**,将其任意重排后得到的本质不同的字符串的数量是多少。Output
问题描述
给定一个字符串$S$。可以得到多少个不同的字符串,作为$S$的一个非空的、不一定连续的子序列的排列?
由于计数可能非常大,因此请将其对$998244353$取模。
约束
- $S$是一个长度在$1$到$5000$(包括)之间,由小写英文字母组成的字符串。
输入
从标准输入按照以下格式获取输入:
$S$
输出
对$S$的子序列进行排列后可以得到的不同字符串的数量,对$998244353$取模。
样例输入1
aab
样例输出1
8
对于给定的字符串$S$,可以得到$8$个不同的字符串作为其子序列的排列:a
,b
,aa
,ab
,ba
,aab
,aba
,baa
。
样例输入2
aaa
样例输出2
3
样例输入3
abcdefghijklmnopqrstuvwxyz
样例输出3
149621752
请确保对计数取模$998244353$。