結果

問題 No.1489 Repeat Cumulative Sum
ユーザー H3PO4H3PO4
提出日時 2022-07-31 08:38:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 442 ms / 2,000 ms
コード長 333 bytes
コンパイル時間 631 ms
コンパイル使用メモリ 10,792 KB
実行使用メモリ 18,960 KB
最終ジャッジ日時 2023-09-28 04:02:44
合計ジャッジ時間 9,264 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
7,784 KB
testcase_01 AC 13 ms
7,780 KB
testcase_02 AC 13 ms
7,808 KB
testcase_03 AC 327 ms
16,416 KB
testcase_04 AC 309 ms
15,968 KB
testcase_05 AC 333 ms
16,584 KB
testcase_06 AC 274 ms
15,012 KB
testcase_07 AC 182 ms
12,820 KB
testcase_08 AC 121 ms
10,752 KB
testcase_09 AC 410 ms
17,928 KB
testcase_10 AC 334 ms
16,496 KB
testcase_11 AC 267 ms
15,088 KB
testcase_12 AC 24 ms
8,284 KB
testcase_13 AC 254 ms
14,208 KB
testcase_14 AC 411 ms
18,960 KB
testcase_15 AC 400 ms
18,316 KB
testcase_16 AC 203 ms
13,056 KB
testcase_17 AC 231 ms
13,728 KB
testcase_18 AC 179 ms
12,596 KB
testcase_19 AC 117 ms
10,684 KB
testcase_20 AC 153 ms
12,008 KB
testcase_21 AC 278 ms
15,104 KB
testcase_22 AC 36 ms
8,796 KB
testcase_23 AC 97 ms
10,428 KB
testcase_24 AC 14 ms
7,912 KB
testcase_25 AC 69 ms
9,712 KB
testcase_26 AC 442 ms
18,956 KB
testcase_27 AC 246 ms
12,716 KB
testcase_28 AC 32 ms
8,544 KB
testcase_29 AC 169 ms
11,264 KB
権限があれば一括ダウンロードができます

ソースコード

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