結果

問題 No.1102 Remnants
ユーザー 👑 KazunKazun
提出日時 2021-06-16 20:34:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 494 ms
コンパイル使用メモリ 82,532 KB
実行使用メモリ 114,460 KB
最終ジャッジ日時 2024-06-10 01:15:22
合計ジャッジ時間 3,515 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,136 KB
testcase_01 AC 34 ms
52,560 KB
testcase_02 AC 33 ms
52,932 KB
testcase_03 AC 36 ms
52,736 KB
testcase_04 AC 41 ms
53,036 KB
testcase_05 AC 130 ms
114,460 KB
testcase_06 AC 51 ms
73,176 KB
testcase_07 AC 136 ms
110,276 KB
testcase_08 AC 46 ms
63,952 KB
testcase_09 AC 45 ms
64,712 KB
testcase_10 AC 45 ms
63,432 KB
testcase_11 AC 46 ms
64,460 KB
testcase_12 AC 45 ms
66,376 KB
testcase_13 AC 46 ms
65,524 KB
testcase_14 AC 80 ms
94,968 KB
testcase_15 AC 68 ms
87,388 KB
testcase_16 AC 116 ms
111,200 KB
testcase_17 AC 121 ms
111,644 KB
testcase_18 AC 125 ms
106,312 KB
testcase_19 AC 81 ms
87,236 KB
testcase_20 AC 50 ms
72,464 KB
testcase_21 AC 94 ms
98,144 KB
testcase_22 AC 112 ms
107,588 KB
testcase_23 AC 93 ms
99,060 KB
testcase_24 AC 82 ms
91,412 KB
testcase_25 AC 127 ms
106,084 KB
testcase_26 AC 55 ms
67,172 KB
testcase_27 AC 69 ms
85,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,input().split())
A=["*"]+list(map(int,input().split()))

Mod=10**9+7
Inv=[0]*(N+1); Inv[1]=1
for i in range(2,N+1):
    q,r=divmod(Mod,i)
    Inv[i]=-q*Inv[r]%Mod

L=[0]*(N+1); L[1]=1
for i in range(2,N+1):
    b=(i+K-1)*Inv[i-1]%Mod
    L[i]=b*L[i-1]%Mod

R=[0]*(N+1); R[N]=1
for i in range(N-1,0,-1):
    b=(N-i+K)*Inv[N-i]
    R[i]=b*R[i+1]%Mod

X=0
for a,l,r in zip(A[1:],L[1:],R[1:]):
    X+=a*((l*r)%Mod)
    X%=Mod

print(X)
0