結果

問題 No.1489 Repeat Cumulative Sum
ユーザー yuruhiyayuruhiya
提出日時 2021-04-23 23:20:54
言語 Ruby
(3.3.0)
結果
AC  
実行時間 286 ms / 2,000 ms
コード長 197 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 11,368 KB
実行使用メモリ 25,184 KB
最終ジャッジ日時 2023-09-17 13:09:13
合計ジャッジ時間 7,140 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,120 KB
testcase_01 AC 80 ms
15,404 KB
testcase_02 AC 81 ms
15,324 KB
testcase_03 AC 249 ms
21,572 KB
testcase_04 AC 237 ms
21,260 KB
testcase_05 AC 254 ms
21,504 KB
testcase_06 AC 214 ms
20,896 KB
testcase_07 AC 171 ms
19,716 KB
testcase_08 AC 140 ms
17,988 KB
testcase_09 AC 279 ms
22,180 KB
testcase_10 AC 248 ms
21,276 KB
testcase_11 AC 210 ms
21,064 KB
testcase_12 AC 88 ms
15,348 KB
testcase_13 AC 200 ms
20,676 KB
testcase_14 AC 286 ms
25,104 KB
testcase_15 AC 279 ms
24,884 KB
testcase_16 AC 178 ms
20,236 KB
testcase_17 AC 191 ms
20,472 KB
testcase_18 AC 166 ms
19,248 KB
testcase_19 AC 136 ms
17,740 KB
testcase_20 AC 151 ms
17,984 KB
testcase_21 AC 213 ms
20,836 KB
testcase_22 AC 89 ms
15,340 KB
testcase_23 AC 107 ms
16,480 KB
testcase_24 AC 79 ms
15,028 KB
testcase_25 AC 113 ms
16,356 KB
testcase_26 AC 286 ms
25,184 KB
testcase_27 AC 170 ms
20,744 KB
testcase_28 AC 88 ms
15,432 KB
testcase_29 AC 146 ms
19,192 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:2: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

M = 10**9 + 7
n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b, c = 1, 1
puts a.reverse.each_with_index.sum { |x, i|
	b = b * (m - 1 + i) * (i + 1).pow(M - 2, M) % M
	c += b
	c * x
} % M
0