問題一覧 > 通常問題

No.802 Roughly Arithmetic Sequence

レベル : / AI推定難易度 : 1950 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 111
作問者 : tempura_pp / テスター : heno239
お気に入りにしたユーザー ProblemId : 2778 / 自分の提出
問題文最終更新日: 2019-03-14 18:50:58
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 208 (順位表) の他の問題:

Problem Statement

Find the number, modulo $10^9+7$, of integer sequences $A_1,A_2,...,A_N$ of length $N$ that satisfy all of the following conditions.

  • $1 \le A_1 \le A_2 \le \ ...\ \le A_N \le M$
  • For every integer $i$ such that $1\le i \le N-1$, $D_1 \le A_{i+1}-A_i \le D_2$
Here, two sequences $A'$ and $A''$ are said to be different if there exists some $i$ such that $A'_i\ne A''_i$.

Input

$N\ M\ D_1\ D_2$

  • $2\le N \le 3×10^5$
  • $1\le M\le 10^6$
  • $0\le D_1\le D_2\le M$
  • All inputs are integers.

Output

Output on one line the number of integer sequences satisfying the conditions, modulo $10^9+7$.

Sample

Sample 1
Input
3 5 1 2
Output
8

The following 8 sequences satisfy the conditions.
$(1,2,3), (1,2,4), (1,3,4), (1,3,5), (2,3,4), (2,3,5), (2,4,5), (3,4,5)$

Sample 2
Input
3 5 2 2
Output
1

Sample 3
Input
5 2 1 1
Output
0

Sample 4
Input
3141 592653 58 97
Output
200759484

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。