結果
| 問題 | No.1489 Repeat Cumulative Sum | 
| コンテスト | |
| ユーザー |  rlangevin | 
| 提出日時 | 2023-11-19 13:39:36 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 174 ms / 2,000 ms | 
| コード長 | 314 bytes | 
| コンパイル時間 | 248 ms | 
| コンパイル使用メモリ | 81,920 KB | 
| 実行使用メモリ | 92,144 KB | 
| 最終ジャッジ日時 | 2024-09-26 06:16:21 | 
| 合計ジャッジ時間 | 4,650 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 27 | 
ソースコード
N, M = map(int, input().split())
N -= 1
A = list(map(int, input().split())) + [0]
mod = 10**9 + 7
comb = M + 1
ans = 0
now = 1
for i in range(N - 1, -1, -1):
    ans += (A[i] - A[i - 1]) * (comb - 1)
    ans %= mod
    comb *= (M + 1 + now) * pow(now + 1, mod - 2, mod)
    comb %= mod
    now += 1
    
print(ans)
            
            
            
        