atcoder#ARC110D. [ARC110D] Binomial Coefficient is Fun
[ARC110D] Binomial Coefficient is Fun
Score : points
Problem Statement
We have a sequence of non-negative integers.
Compute the sum of over all sequences of non-negative integers whose sum is at most , and print it modulo ().
Here, , the binomial coefficient, denotes the number of ways to choose objects from objects, and is when .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the sum of , modulo .
3 5
1 2 1
8
There are four sequences such that is at least :
- , where $\prod _{i = 1} ^N \dbinom{B_i}{A_i} = \dbinom{1}{1} \times \dbinom{2}{2} \times \dbinom{1}{1} = 1$;
- , where $\prod _{i = 1} ^N \dbinom{B_i}{A_i} = \dbinom{2}{1} \times \dbinom{2}{2} \times \dbinom{1}{1} = 2$;
- , where $\prod _{i = 1} ^N \dbinom{B_i}{A_i} = \dbinom{1}{1} \times \dbinom{3}{2} \times \dbinom{1}{1} = 3$;
- , where $\prod _{i = 1} ^N \dbinom{B_i}{A_i} = \dbinom{1}{1} \times \dbinom{2}{2} \times \dbinom{2}{1} = 2$.
The sum of these is .
10 998244353
31 41 59 26 53 58 97 93 23 84
642612171