結果
問題 |
No.988 N×Mマス計算(総和)
|
ユーザー |
![]() |
提出日時 | 2021-02-03 19:24:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 494 bytes |
コンパイル時間 | 1,360 ms |
コンパイル使用メモリ | 165,396 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-30 03:33:07 |
合計ジャッジ時間 | 2,689 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 |
other | AC * 2 WA * 17 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:27:25: warning: 'sum_a' may be used uninitialized [-Wmaybe-uninitialized] 27 | cout << ((n * sum_a) % k + (m * sum_b) % k) % k << endl; | ~~~^~~~~~~~ main.cpp:10:9: note: 'sum_a' was declared here 10 | int sum_a , sum_b = 0; | ^~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int n , m , k; cin >> n >> m >> k; char op; int sum_a , sum_b = 0; cin >> op; for(int i = 0; i < m; i++){ int a; cin >> a; sum_a += a; sum_a %= k; } for(int i = 0; i < n; i++){ int b; cin >> b; sum_b += b; sum_b %= k; } if(op == '*'){ cout << (sum_a * sum_b) % k << endl; }else{ cout << ((n * sum_a) % k + (m * sum_b) % k) % k << endl; } return 0; }