atcoder#ARC138E. [ARC138E] Decreasing Subsequence
[ARC138E] Decreasing Subsequence
Score : points
Problem Statement
You are given integers and . Let us call an integer sequence good when it satisfies all of the conditions below.
- ()
- For every integer , there is at most one index such that .
Find the sum, modulo , of the answers to the following problem for all good sequences .
- Find the number of length- (not necessarily contiguous) subsequences of consisting of positive integers that are decreasing. In other words, find the number of sequences of indices such that .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3 2
1
For example, is a good sequence, with one subsequence satisfying the condition. There are other good sequences such as , but none of them has subsequences satisfying the condition. In the end, no good sequence other than has subsequences satisfying the condition, so the answer is .
6 2
660
10 3
242595
100 10
495811864