結果

問題 No.1102 Remnants
ユーザー marroncastlemarroncastle
提出日時 2020-07-27 23:56:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 882 ms / 2,000 ms
コード長 408 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 10,816 KB
実行使用メモリ 31,544 KB
最終ジャッジ日時 2023-09-11 06:10:03
合計ジャッジ時間 11,404 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,740 KB
testcase_01 AC 16 ms
7,776 KB
testcase_02 AC 16 ms
7,684 KB
testcase_03 AC 16 ms
7,764 KB
testcase_04 AC 16 ms
7,768 KB
testcase_05 AC 717 ms
25,464 KB
testcase_06 AC 127 ms
11,544 KB
testcase_07 AC 882 ms
31,544 KB
testcase_08 AC 29 ms
8,460 KB
testcase_09 AC 52 ms
9,052 KB
testcase_10 AC 21 ms
8,200 KB
testcase_11 AC 42 ms
8,724 KB
testcase_12 AC 57 ms
9,080 KB
testcase_13 AC 53 ms
9,084 KB
testcase_14 AC 399 ms
17,212 KB
testcase_15 AC 313 ms
16,004 KB
testcase_16 AC 800 ms
29,388 KB
testcase_17 AC 757 ms
27,120 KB
testcase_18 AC 775 ms
28,288 KB
testcase_19 AC 266 ms
15,092 KB
testcase_20 AC 91 ms
10,208 KB
testcase_21 AC 461 ms
20,332 KB
testcase_22 AC 654 ms
25,420 KB
testcase_23 AC 510 ms
21,448 KB
testcase_24 AC 368 ms
17,544 KB
testcase_25 AC 786 ms
28,836 KB
testcase_26 AC 59 ms
9,264 KB
testcase_27 AC 213 ms
14,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())
A = list(map(int, input().split()))

def combs_mod(n,k,mod):
  #nC0からnCkまで
  inv = [1]*(n+1)
  for i in range(1,n):
    inv[i] = pow(i,mod-2,mod)
  ans = [1]*(n+1)
  for i in range(1,n):
    ans[i] = ans[i-1]*(k+i)*inv[i]%mod
  return ans

ans = 0
mod = 10**9+7
combs = combs_mod(N,K,mod)
for i in range(N):
  ans += A[i]*combs[i]*combs[N-1-i]
  ans %= mod
print(ans)
0