Counting Sequence
Time limit16sMemory limit1024 MB
Count sequences of positive integers with adjacent differences of 1 and sum n, weighting each by c raised to the number of descents, modulo 998244353.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Math, Combinatorics
- Solved
- No attempts yet
Problem
We are given integers and .
A sequence is good if and only if:
- for all ,
- for all ,
- .
For a good sequence , define
That is, is the number of indices with such that . The weight of a sequence is .
Compute the sum of the weights of all good sequences, modulo 998244353.
Input
The first line contains two integers and (, ).
Output
Output the answer modulo 998244353.
Hint
In the first example, all good sequences are as follows:
So the answer is .