結果
問題 | No.1102 Remnants |
ユーザー |
![]() |
提出日時 | 2020-07-06 22:22:14 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,315 ms / 2,000 ms |
コード長 | 595 bytes |
コンパイル時間 | 650 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 42,160 KB |
最終ジャッジ日時 | 2024-09-24 18:30:53 |
合計ジャッジ時間 | 17,611 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
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)