結果
問題 | No.2941 Sigma Music Game Score Problem |
ユーザー |
|
提出日時 | 2024-10-27 13:19:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,035 bytes |
コンパイル時間 | 2,071 ms |
コンパイル使用メモリ | 196,000 KB |
最終ジャッジ日時 | 2025-02-25 00:50:11 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 WA * 12 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, s, e) for (int i = (int)s; i < (int)e; ++i) #define all(a) (a).begin(), (a).end() const ll mod = 998244353ll; ll modpow(ll a, ll n, ll m) { ll res = 1; while (n > 0) { if (n & 1) res = res * a % m; a = a * a % m; n >>= 1; } return res; } ll modinv(ll a, ll m) { return modpow(a, m - 2, m); } int main() { cin.tie(nullptr); ll M, N; cin >> M >> N; if (N == 0) { cout << M * (M + 1) % mod * (2 * M + 1) % mod * modinv(6, mod) % mod; return 0; } vector<ll> X(N); rep(i, 0, N) cin >> X[i]; ll ans = 0; ll now = 1; ll k; rep(i, 0, N) { k = X[i] - now; ans += k * (k + 1) % mod * (2 * k + 1) % mod * modinv(6, mod) % mod; ans %= mod; now = X[i] + 1; } k = M - X[N - 1]; ans += k * (k + 1) % mod * (2 * k + 1) % mod * modinv(6, mod) % mod; ans %= mod; cout << ans << '\n'; }