結果
問題 | No.2144 MM |
ユーザー |
|
提出日時 | 2024-04-20 08:40:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 82 ms / 2,000 ms |
コード長 | 480 bytes |
コンパイル時間 | 4,185 ms |
コンパイル使用メモリ | 250,580 KB |
最終ジャッジ日時 | 2025-02-21 06:04:36 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>using namespace std;int main(){int n, m;cin >> n >> m;vector<int> a(n);for(auto &v:a)cin >> v;long long s = 0;atcoder::modint998244353 ans, d = 1;for(int i = 0; i < n; i++){s += (i & 1 ? -a[i] : a[i]);ans += d * a.rbegin()[i];d *= m - 1;}if(s % m){cout << -1 << '\n';return 0;}ans /= m;ans++;cout << ans.val() << '\n';}