結果

問題 No.2941 Sigma Music Game Score Problem
ユーザー LyricalMaestro
提出日時 2024-10-20 23:55:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 307 ms / 2,500 ms
コード長 635 bytes
コンパイル時間 667 ms
コンパイル使用メモリ 82,200 KB
実行使用メモリ 262,280 KB
最終ジャッジ日時 2024-10-20 23:55:51
合計ジャッジ時間 7,499 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

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


MOD = 998244353

inv6 = pow(6, MOD - 2, MOD)

def sigma_n2(n):
    ans = (n * (n + 1) )% MOD
    ans *= (2 * n + 1) % MOD
    ans %= MOD
    ans *= inv6
    ans %= MOD
    return ans


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

    X_ = [0] + X + [M + 1]
    answer = 0
    for i in range(len(X_) - 1):
        x0 = X_[i]
        x1 = X_[i + 1]
        if x1 - x0 > 1:
            n = x1 - x0 - 1

            a = sigma_n2(n)
            answer += a
            answer %= MOD
    print(answer)














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