結果

問題 No.1489 Repeat Cumulative Sum
ユーザー rlangevinrlangevin
提出日時 2023-11-19 13:39:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 314 bytes
コンパイル時間 340 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 91,948 KB
最終ジャッジ日時 2023-11-19 13:39:41
合計ジャッジ時間 4,539 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 34 ms
53,460 KB
testcase_02 AC 34 ms
53,460 KB
testcase_03 AC 125 ms
87,880 KB
testcase_04 AC 119 ms
86,348 KB
testcase_05 AC 125 ms
87,928 KB
testcase_06 AC 116 ms
84,916 KB
testcase_07 AC 90 ms
81,236 KB
testcase_08 AC 70 ms
75,304 KB
testcase_09 AC 138 ms
89,932 KB
testcase_10 AC 126 ms
87,892 KB
testcase_11 AC 111 ms
84,808 KB
testcase_12 AC 47 ms
62,352 KB
testcase_13 AC 107 ms
83,568 KB
testcase_14 AC 150 ms
91,792 KB
testcase_15 AC 146 ms
91,576 KB
testcase_16 AC 99 ms
82,208 KB
testcase_17 AC 104 ms
83,376 KB
testcase_18 AC 88 ms
81,256 KB
testcase_19 AC 69 ms
75,260 KB
testcase_20 AC 77 ms
77,464 KB
testcase_21 AC 110 ms
84,904 KB
testcase_22 AC 47 ms
64,444 KB
testcase_23 AC 68 ms
72,320 KB
testcase_24 AC 35 ms
53,460 KB
testcase_25 AC 56 ms
68,808 KB
testcase_26 AC 149 ms
91,948 KB
testcase_27 AC 102 ms
84,652 KB
testcase_28 AC 47 ms
64,444 KB
testcase_29 AC 87 ms
78,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0