結果

問題 No.1489 Repeat Cumulative Sum
コンテスト
ユーザー LyricalMaestro
提出日時 2025-11-25 00:12:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 626 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 82,796 KB
実行使用メモリ 86,508 KB
最終ジャッジ日時 2025-11-25 00:12:54
合計ジャッジ時間 4,542 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

## https://yukicoder.me/problems/no/1693

MOD = 10 ** 9 + 7
MAX_INT = 10 ** 18

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    answer = 0
    c = 1
    m0 = M
    m1 = 1
    for a in reversed(A):
        c *= m0
        c %= MOD
        c *= pow(m1, MOD - 2, MOD)
        c %= MOD

        d = (c - 1) % MOD
        answer += (a * d) % MOD
        answer %= MOD

        m0 += 1
        m0 %= MOD
        m1 += 1
        m1 %= MOD
    
    for a in A:
        answer += a
        answer %= MOD
    print(answer)





    


        

    



if __name__ == "__main__":
    main()
0