問題一覧 > 通常問題

No.1489 Repeat Cumulative Sum

レベル : / AI推定難易度 : 1875 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 74
作問者 : ytqm3 / テスター : magsta
お気に入りにしたユーザー ProblemId : 6229 / 自分の提出
問題文最終更新日: 2022-04-16 18:52:05
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 292 (順位表) の他の問題:

Problem Statement

You are given positive integers $N,M$ and a sequence of positive integers $A=(A_2,A_3,\ldots,A_N)$ of length $N-1$. Note that the indices of $A$ start from $2$.

Consider an $N\times M$ matrix $B$ satisfying the following conditions.

  • For every $j$ satisfying $1 \le j \le M$, $B_{1,j}=0$
  • For every $i$ satisfying $2 \le i \le N$, $B_{i,1}=A_i$
  • For every pair $(i,j)$ satisfying $2 \le i \le N$ , $2 \le j \le M$, $B_{i,j}=B_{i-1,j}+B_{i,j-1}$

It can be shown that the $B$ satisfying the conditions is uniquely determined. Find $\displaystyle \sum_{i=1}^{N} \sum_{j=1}^{M} B_{i,j}$ modulo $10^9+7$.

Constraints

  • All input values are integers.
  • $2 \le N \le 10^5$
  • $2 \le M \le 10^{18}$
  • $1 \le A_i \le 10^9\ (2 \le i \le N)$

Input

The input is given from standard input in the following format.

$N$ $M$
$A_2$ $A_3$ $\ldots$ $A_N$

Output

Output the answer.

Sample 1


Sample Input 1

4 2
1 2 3

Sample Output 1

16

Since $B_{1,1}=0,B_{1,2}=0,B_{2,1}=1,B_{2,2}=1,B_{3,1}=2,B_{3,2}=3,B_{4,1}=3,B_{4,2}=6$, we have $\displaystyle \sum_{i=1}^{N} \sum_{j=1}^{M} B_{i,j}=16$.

Sample 2


Sample Input 2

2 200000
1

Sample Output 2

200000

Sample 3


Sample Input 3

4 141592
65 35 89

Sample Output 3

406519592

Don't forget to find the remainder when divided by $10^9+7$.

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