結果

問題 No.1489 Repeat Cumulative Sum
ユーザー roarisroaris
提出日時 2021-04-23 23:06:55
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 737 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 86,288 KB
実行使用メモリ 95,336 KB
最終ジャッジ日時 2023-09-17 13:03:02
合計ジャッジ時間 7,052 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
80,448 KB
testcase_01 AC 88 ms
80,332 KB
testcase_02 AC 87 ms
80,292 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 116 ms
82,056 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

MAX = 2*10**5+100
MOD = 10**9+7
fact = [0]*MAX #fact[i]: i!
inv = [0]*MAX #inv[i]: iの逆元
finv = [0]*MAX #finv[i]: i!の逆元
fact[0] = 1
fact[1] = 1
finv[0] = 1
finv[1] = 1
inv[1] = 1
    
for i in range(2, MAX):
    fact[i] = fact[i-1]*i%MOD
    inv[i] = MOD-inv[MOD%i]*(MOD//i)%MOD
    finv[i] = finv[i-1]*inv[i]%MOD

def C(n, r):
    if n<r:
        return 0
    if n<0 or r<0:
        return 0
    return fact[n]*(finv[r]*finv[n-r]%MOD)%MOD

def f(n, m):
    return ((n+2)*C(n+m+2, m)%MOD-m-1)*pow(m+1, MOD-2, MOD)%MOD

N, M = map(int, input().split())
A = list(map(int, input().split()))
ans = sum(A)%MOD

for i in range(N-1):
    ans += f(N-i-2, M-2)*A[i]%MOD
    ans %= MOD

print(ans)
0