結果

問題 No.2941 Sigma Music Game Score Problem
ユーザー srjywrdnprkt
提出日時 2024-10-19 20:45:08
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 153 ms / 2,500 ms
コード長 528 bytes
コンパイル時間 2,047 ms
コンパイル使用メモリ 195,660 KB
最終ジャッジ日時 2025-02-24 21:42:11
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>

using namespace std;
using ll = long long;
using namespace atcoder;
using mint = modint998244353;

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    ll M, N, p=0, X;
    mint Y, ans=0, iv=mint(6).inv();
    cin >> M >> N;
    M++;

    for (int i=0; i<N; i++){
        cin >> X;
        Y = X-p-1;
        ans += Y*(Y+1)*(Y*2+1)*iv;
        p = X;
    }

    Y = M-p-1;
    ans += Y*(Y+1)*(Y*2+1)*iv;
    cout << ans.val() << endl;

    return 0;
}
0