結果

問題 No.1489 Repeat Cumulative Sum
ユーザー H3PO4H3PO4
提出日時 2022-07-31 08:38:50
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 592 ms / 2,000 ms
コード長 333 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 21,512 KB
最終ジャッジ日時 2024-07-20 22:37:12
合計ジャッジ時間 10,537 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
A = map(int, input().split())
MOD = 10 ** 9 + 7
modinv = lambda x, mod=MOD: pow(x, mod - 2, mod)

comb = [0] * (N + 1)
comb[0] = 1
for i in range(N):
    comb[i + 1] = comb[i] * (M + i) * modinv(i + 1) % MOD

ans = 0
for i, a in enumerate(A):
    ans += a * comb[N - 1 - i]
    ans %= MOD
print(ans)
0