結果

問題 No.1102 Remnants
ユーザー takakintakakin
提出日時 2020-07-06 22:22:14
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,079 ms / 2,000 ms
コード長 595 bytes
コンパイル時間 116 ms
コンパイル使用メモリ 11,884 KB
実行使用メモリ 41,328 KB
最終ジャッジ日時 2023-10-24 23:28:17
合計ジャッジ時間 15,062 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 169 ms
25,808 KB
testcase_01 AC 175 ms
25,808 KB
testcase_02 AC 174 ms
25,808 KB
testcase_03 AC 174 ms
25,808 KB
testcase_04 AC 171 ms
25,808 KB
testcase_05 AC 890 ms
32,148 KB
testcase_06 AC 294 ms
27,848 KB
testcase_07 AC 1,079 ms
41,328 KB
testcase_08 AC 182 ms
25,752 KB
testcase_09 AC 214 ms
26,440 KB
testcase_10 AC 175 ms
25,752 KB
testcase_11 AC 198 ms
26,016 KB
testcase_12 AC 214 ms
26,516 KB
testcase_13 AC 206 ms
26,216 KB
testcase_14 AC 577 ms
29,864 KB
testcase_15 AC 486 ms
31,148 KB
testcase_16 AC 1,011 ms
38,716 KB
testcase_17 AC 959 ms
37,864 KB
testcase_18 AC 958 ms
39,228 KB
testcase_19 AC 438 ms
30,516 KB
testcase_20 AC 251 ms
26,944 KB
testcase_21 AC 644 ms
34,076 KB
testcase_22 AC 855 ms
37,140 KB
testcase_23 AC 691 ms
34,660 KB
testcase_24 AC 539 ms
32,268 KB
testcase_25 AC 984 ms
39,448 KB
testcase_26 AC 213 ms
26,572 KB
testcase_27 AC 373 ms
29,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n,k=map(int,input().split())
A=[int(i) for i in input().split()]
mod=10**9+7
n_max=2*(10**5+1)
F,FI=[0]*(n_max+1),[0]*(n_max+1)
F[0],FI[0]=1,1
for i in range(n_max):
  F[i+1]=(F[i]*(i+1))%mod
FI[n_max-1]=pow(F[n_max-1],mod-2,mod)
for i in reversed(range(n_max-1)):
  FI[i]=(FI[i+1]*(i+1))%mod
def comb(x,y):
  return (F[x]*FI[x-y]*FI[y])%mod
def hom(x,y):
  return comb(x+y-1,y)

H=[0]*(n+1)
H[0]=1
for i in range(n):
  H[i+1]=(H[i]*(k+i+1)*pow(i+1,mod-2,mod))%mod
ans=0
for i,a in enumerate(A):
  ans=(ans+a*(H[i]*H[n-i-1]))%mod
print(ans)
0