E - Sequence 3
Editorial
/
/
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 3 点
問題文
M 以下の正整数からなる長さ N の整数列 A = (a_1,a_2,\dots,a_N) のうち、次の条件を満たすものの個数を 998244353 で割った余りを求めてください。
- 1 \leq m \leq M を満たす整数 m 全てについて、A における m の登場回数は m 回以下である。
制約
- 1 \leq N \leq 300
- 1 \leq M \leq 300
- N, M は整数
入力
入力は以下の形式で標準入力から与えられる。
N M
出力
答えを出力せよ。
入力例 1
2 3
出力例 1
8
条件を満たす数列は次の 8 個です。
- (1, 2)
- (1, 3)
- (2, 1)
- (2, 2)
- (2, 3)
- (3, 1)
- (3, 2)
- (3, 3)
入力例 2
300 300
出力例 2
478329414
Score: 3 points
Problem Statement
Consider integer sequences A = (a_1,a_2,\dots,a_N) of length N, where each element is a positive integer not greater than M.
Count how many such sequences satisfy the following condition, and output the result modulo 998244353.
- For every integer m such that 1 \leq m \leq M, the number of times m appears in A is at most m.
Constraints
- 1 \leq N \leq 300
- 1 \leq M \leq 300
- N, M are integers
Input
The input is given from standard input in the following format:
N M
Output
Print the answer.
Sample Input 1
2 3
Sample Output 1
8
There are 8 sequences that satisfy the condition:
- (1, 2)
- (1, 3)
- (2, 1)
- (2, 2)
- (2, 3)
- (3, 1)
- (3, 2)
- (3, 3)
Sample Input 2
300 300
Sample Output 2
478329414