No.1939 Numbered Colorful Balls
Problem Statement
There are plenty of balls of every kind, where each ball is painted in exactly $1$ of the colors color $1,$ color $2,\dots$ and has exactly $1$ of the numbers $1,2,\dots$ written on it.
A row of balls arranged from left to right is called a good row of balls if it can be made empty by repeating the following operation.
Find the number of good rows of balls that can be formed by arranging $N$ balls, and print it modulo $998244353$.
Constraints
Input
$N\ M$ $l_1\ l_2\ \dots l_M$
Output
Find the number of good rows of balls that can be formed by arranging $N$ balls, and print it modulo $998244353$.
Sample
Sample 1
Input
3 2 1 2
Output
4
Let $(i,j)$ denote a ball painted in color $i$ with the number $j$ written on it. The following $4$ rows are the good rows of balls that can be formed by arranging $3$ balls.
Sample 2
Input
100 1 2
Output
512803529
Find the answer modulo $998244353$.
Sample 3
Input
55555 5 5 55 555 5555 55555
Output
118151184
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
noya2
tatyam
hamamu