結果
| 問題 |
No.988 N×Mマス計算(総和)
|
| コンテスト | |
| ユーザー |
square1001
|
| 提出日時 | 2020-02-14 21:22:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 91 ms / 2,000 ms |
| コード長 | 703 bytes |
| コンパイル時間 | 655 ms |
| コンパイル使用メモリ | 76,564 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-06 06:50:46 |
| 合計ジャッジ時間 | 2,023 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 19 |
ソースコード
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
int N, M, K; string op;
cin >> N >> M >> K >> op;
vector<int> B(M), A(N);
for (int i = 0; i < M; ++i) cin >> B[i];
for (int i = 0; i < N; ++i) cin >> A[i];
if (op == "+") {
int ans = 0;
for (int i = 0; i < N; ++i) {
ans = (ans + 1LL * A[i] * M) % K;
}
for (int i = 0; i < M; ++i) {
ans = (ans + 1LL * B[i] * N) % K;
}
cout << ans << endl;
}
else {
int as = 0, bs = 0;
for (int i = 0; i < N; ++i) {
as = (as + A[i]) % K;
}
for (int i = 0; i < M; ++i) {
bs = (bs + B[i]) % K;
}
cout << 1LL * as * bs % K << endl;
}
return 0;
}
square1001