結果
| 問題 |
No.2144 MM
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-12-02 23:57:01 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 455 bytes |
| コンパイル時間 | 730 ms |
| コンパイル使用メモリ | 90,348 KB |
| 最終ジャッジ日時 | 2024-11-15 02:52:04 |
| 合計ジャッジ時間 | 1,288 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:6:5: error: 'cin' was not declared in this scope
6 | cin >> n >> m;
| ^~~
main.cpp:2:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
1 | #include <atcoder/all>
+++ |+#include <iostream>
2 | using namespace std;
main.cpp:17:9: error: 'cout' was not declared in this scope
17 | cout << -1 << '\n';
| ^~~~
main.cpp:17:9: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
main.cpp:22:5: error: 'cout' was not declared in this scope
22 | cout << ans.val() << '\n';
| ^~~~
main.cpp:22:5: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
ソースコード
#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';
}