

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
整数 が与えられます. 以下の条件をすべて満たす整数列 を,よい数列と呼ぶことにします.
- ()
- 各整数 について, となる は高々 つ.
すべてのよい数列 について以下の問題の答えを足し合わせた値を で割った余りを求めてください.
- の長さ の(連続するとは限らない)部分列であって,正整数のみからなり,かつ単調減少であるようなものは何通りあるか求めよ. 別の言い方をすれば,添字の列 であって, を満たすものの個数を求めよ.
制約
- 入力される値はすべて整数
入力
入力は以下の形式で標準入力から与えられる.
出力
答えを出力せよ.
入力例 1Copy
3 2
出力例 1Copy
1
例えば はよい数列であり,条件を満たす部分列の個数は です. それ以外のよい数列の例としては などが考えられますが,どれも条件を満たす部分列が存在しません. 結局, 以外のよい数列は条件を満たす部分列を持たず,よって答えは になります.
入力例 2Copy
6 2
出力例 2Copy
660
入力例 3Copy
10 3
出力例 3Copy
242595
入力例 4Copy
100 10
出力例 4Copy
495811864
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.
Sample Input 1Copy
3 2
Sample Output 1Copy
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 .
Sample Input 2Copy
6 2
Sample Output 2Copy
660
Sample Input 3Copy
10 3
Sample Output 3Copy
242595
Sample Input 4Copy
100 10
Sample Output 4Copy
495811864