結果

問題 No.1102 Remnants
ユーザー yuruhiyayuruhiya
提出日時 2020-07-05 11:56:18
言語 Ruby
(3.2.2)
結果
AC  
実行時間 508 ms / 2,000 ms
コード長 270 bytes
コンパイル時間 489 ms
コンパイル使用メモリ 11,920 KB
実行使用メモリ 33,828 KB
最終ジャッジ日時 2023-10-22 06:26:40
合計ジャッジ時間 8,185 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
16,092 KB
testcase_01 AC 87 ms
16,092 KB
testcase_02 AC 86 ms
16,092 KB
testcase_03 AC 86 ms
16,092 KB
testcase_04 AC 86 ms
16,092 KB
testcase_05 AC 316 ms
31,816 KB
testcase_06 AC 127 ms
18,912 KB
testcase_07 AC 508 ms
33,828 KB
testcase_08 AC 92 ms
16,092 KB
testcase_09 AC 100 ms
16,452 KB
testcase_10 AC 91 ms
16,232 KB
testcase_11 AC 100 ms
16,384 KB
testcase_12 AC 106 ms
16,480 KB
testcase_13 AC 99 ms
16,468 KB
testcase_14 AC 215 ms
22,260 KB
testcase_15 AC 187 ms
21,680 KB
testcase_16 AC 370 ms
32,644 KB
testcase_17 AC 440 ms
32,260 KB
testcase_18 AC 450 ms
33,012 KB
testcase_19 AC 215 ms
21,588 KB
testcase_20 AC 124 ms
17,376 KB
testcase_21 AC 304 ms
26,088 KB
testcase_22 AC 398 ms
31,316 KB
testcase_23 AC 333 ms
26,480 KB
testcase_24 AC 266 ms
22,396 KB
testcase_25 AC 456 ms
33,116 KB
testcase_26 AC 108 ms
16,404 KB
testcase_27 AC 185 ms
20,972 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

MOD = 1_000_000_007
n, k = gets.split.map &:to_i
a = gets.split.map &:to_i

comb = [0] * (n + 1)
comb[0] = 1
(1..n).each { |i| comb[i] = comb[i - 1] * (i + k) * i.pow(MOD - 2, MOD) % MOD }

puts a.each_with_index.sum { |v, i| v * comb[i] * comb[n - i - 1] % MOD } % MOD
0