No.3178 free sort
タグ : / 解いたユーザー数 118
作問者 :
Cafe1942
/ テスター :
tsunamayo123
Problem Statement
You are given a positive integer $N$. Consider the digits of $N$ when written in decimal so that the most significant digit is not $0$. You may freely rearrange these digits, as long as the most significant digit does not become $0$. How many positive integers can be formed in total? Since the answer can be very large, output the answer modulo $998244353$.
(Added at $21$:$48$) Some test cases begin with a leading $0$. In every test case, the number of digits (characters) is at most $200000$. (Added at 22:26) For cases with a leading 0, output the number of ways to rearrange the digits using exactly as many 0s as the input contains, so that no 0 comes first.
Constraints
- $1 \leq N < 10^{200000}$
- $N$ is an integer
- (Added at $21$:$48$) Some test cases begin with a leading $0$.
Input
$N$
Output
Output the answer modulo $998244353$.
Sample
Sample 1
Input
120
Output
4
A total of $4$ numbers can be formed: $102$ $,$ $120$ $,$ $201$ $,$ $210$.
Sample 2
Input
9
Output
1
The only number that can be formed is $9$, so there is just $1$ way.
Sample 3
Input
1942
Output
24
Sample 4
Input
1944
Output
12
Sample 5
Input
11123456789995
Output
212565247
The number of ways is $1210809600$, but you should output $212565247$, which is the remainder when divided by $998244353$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。