D - Convex Sequence Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 10001000

問題文

整数 NNMM が与えられます. 長さ NN の非負整数列 (A1,A2,,AN)(A_1,A_2,\ldots,A_N) であって,次の条件を満たすものの個数をmod(109+7)\bmod (10^9+7) で求めてください.

  • A1+A2++AN=MA_1+A_2+\ldots +A_N = M
  • すべての ii (2iN12 \leq i \leq N-1) について,2AiAi1+Ai+12 A_i \leq A_{i-1} + A_{i+1}

制約

  • 1N1051 \leq N \leq 10^5
  • 1M1051 \leq M \leq 10^5
  • 入力はすべて整数である.

入力

入力は以下の形式で標準入力から与えられる.

NN MM

出力

条件を満たす数列の個数をmod(109+7)\bmod (10^9+7) で出力せよ.


入力例 1Copy

Copy
3 3

出力例 1Copy

Copy
7

以下の 77 個の数列が条件を満たします.

  • 0,0,30,0,3
  • 0,1,20,1,2
  • 1,0,21,0,2
  • 1,1,11,1,1
  • 2,0,12,0,1
  • 2,1,02,1,0
  • 3,0,03,0,0

入力例 2Copy

Copy
10 100

出力例 2Copy

Copy
10804516

入力例 3Copy

Copy
10000 100000

出力例 3Copy

Copy
694681734

Score : 10001000 points

Problem Statement

Given are integers NN and MM. Find the number, modulo (109+7)(10^9+7), of length-NN sequences (A1,A2,,AN)(A_1,A_2,\ldots,A_N) that consist of non-negative integers and satisfy the following conditions:

  • A1+A2++AN=MA_1+A_2+\ldots +A_N = M;
  • For every ii (2iN12 \leq i \leq N-1), 2AiAi1+Ai+12 A_i \leq A_{i-1} + A_{i+1}.

Constraints

  • 1N1051 \leq N \leq 10^5
  • 1M1051 \leq M \leq 10^5
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM

Output

Print the number, modulo (109+7)(10^9+7), of sequences that satisfy the conditions.


Sample Input 1Copy

Copy
3 3

Sample Output 1Copy

Copy
7

The following seven sequences satisfy the conditions.

  • 0,0,30,0,3
  • 0,1,20,1,2
  • 1,0,21,0,2
  • 1,1,11,1,1
  • 2,0,12,0,1
  • 2,1,02,1,0
  • 3,0,03,0,0

Sample Input 2Copy

Copy
10 100

Sample Output 2Copy

Copy
10804516

Sample Input 3Copy

Copy
10000 100000

Sample Output 3Copy

Copy
694681734


2025-03-29 (Sat)
14:36:46 +00:00