D - Convex Sequence
Editorial
/


Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
整数 と が与えられます. 長さ の非負整数列 であって,次の条件を満たすものの個数を で求めてください.
- すべての () について,
制約
- 入力はすべて整数である.
入力
入力は以下の形式で標準入力から与えられる.
出力
条件を満たす数列の個数を で出力せよ.
入力例 1Copy
Copy
3 3
出力例 1Copy
Copy
7
以下の 個の数列が条件を満たします.
入力例 2Copy
Copy
10 100
出力例 2Copy
Copy
10804516
入力例 3Copy
Copy
10000 100000
出力例 3Copy
Copy
694681734
Score : points
Problem Statement
Given are integers and . Find the number, modulo , of length- sequences that consist of non-negative integers and satisfy the following conditions:
- ;
- For every (), .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number, modulo , of sequences that satisfy the conditions.
Sample Input 1Copy
Copy
3 3
Sample Output 1Copy
Copy
7
The following seven sequences satisfy the conditions.
Sample Input 2Copy
Copy
10 100
Sample Output 2Copy
Copy
10804516
Sample Input 3Copy
Copy
10000 100000
Sample Output 3Copy
Copy
694681734