Growing Sequences
Time limit1sMemory limit2048 MB
Count arrays of length n where each element is at least twice the previous one and all values lie between 1 and c, modulo 998244353.
- Level
Medium6 of 10
- Topics
- Combinatorics, Math, Dynamic programming
- Solved
- No attempts yet
Problem
Exponentially growing sequences appear often in scientific research. Some researchers are especially interested in integer arrays of length where each element is at least twice the previous one. Formally, holds for every . Count the number of such arrays whose elements are integers from to . The count can be very large, so output it modulo .
Input
The only line contains two integers and (; ): the length of the arrays and the maximum value of their elements.
Output
Output the number of different arrays modulo .
Hint
In the first example, there are different arrays: [1], [2], [3], [4], [5]. In the second example, there are different arrays: [1, 2, 4], [1, 2, 5], [1, 2, 6], [1, 3, 6]. In the third example, there are no arrays satisfying the conditions.