結果

問題 No.1102 Remnants
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-06-30 13:31:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 307 ms / 2,000 ms
コード長 537 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 87,140 KB
実行使用メモリ 113,416 KB
最終ジャッジ日時 2023-09-09 07:40:13
合計ジャッジ時間 6,807 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,540 KB
testcase_01 AC 74 ms
71,408 KB
testcase_02 AC 77 ms
71,348 KB
testcase_03 AC 74 ms
71,556 KB
testcase_04 AC 72 ms
71,336 KB
testcase_05 AC 238 ms
113,416 KB
testcase_06 AC 105 ms
79,708 KB
testcase_07 AC 307 ms
106,536 KB
testcase_08 AC 85 ms
76,620 KB
testcase_09 AC 88 ms
76,528 KB
testcase_10 AC 83 ms
76,848 KB
testcase_11 AC 89 ms
76,592 KB
testcase_12 AC 93 ms
76,876 KB
testcase_13 AC 90 ms
76,896 KB
testcase_14 AC 165 ms
94,192 KB
testcase_15 AC 148 ms
89,724 KB
testcase_16 AC 249 ms
103,708 KB
testcase_17 AC 264 ms
103,536 KB
testcase_18 AC 275 ms
104,600 KB
testcase_19 AC 147 ms
85,968 KB
testcase_20 AC 100 ms
77,740 KB
testcase_21 AC 192 ms
93,700 KB
testcase_22 AC 244 ms
101,728 KB
testcase_23 AC 202 ms
94,120 KB
testcase_24 AC 170 ms
88,308 KB
testcase_25 AC 279 ms
104,864 KB
testcase_26 AC 91 ms
76,648 KB
testcase_27 AC 130 ms
83,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
ary=[0,1]
# ary[i]:k個の区別できる箱にi個の区別できないボールを入れる入れ方
# =cmb(k+i-1,i)=cmb(k+(i-1)-1,(i-1))*(k+i-1)//i
for i in range(1,n+1):
  x=(k+i-1)%mod
  y=pow(i,mod-2,mod)%mod
  ary.append(ary[-1]*x*y%mod)
for i in range(len(ary)-1):
  ary[i+1]+=ary[i]
  ary[i+1]%=mod
for i in range(n):
  # k回の操作でlはi以下,rはi以上を選び続ける。
  tmp=a[i]*ary[i+1]*ary[n-i]%mod
  ans+=tmp
  ans%=mod
print(ans)
0