結果

問題 No.988 N×Mマス計算(総和)
ユーザー ninoinuininoinui
提出日時 2020-02-14 22:40:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 521 bytes
コンパイル時間 1,571 ms
コンパイル使用メモリ 167,068 KB
実行使用メモリ 4,740 KB
最終ジャッジ日時 2023-09-20 12:01:03
合計ジャッジ時間 3,142 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 23 ms
4,380 KB
testcase_11 AC 35 ms
4,376 KB
testcase_12 AC 57 ms
4,384 KB
testcase_13 AC 28 ms
4,376 KB
testcase_14 AC 25 ms
4,376 KB
testcase_15 AC 24 ms
4,380 KB
testcase_16 AC 49 ms
4,380 KB
testcase_17 AC 61 ms
4,396 KB
testcase_18 AC 33 ms
4,380 KB
testcase_19 AC 56 ms
4,380 KB
testcase_20 AC 83 ms
4,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M, K;
  char op;
  cin >> N >> M >> K >> op;
  vector<long> A(N), B(M);
  for (auto &b : B) cin >> b;
  for (auto &a : A) cin >> a;

  long ans = 0;
  if (op == '+') {
    for (int i = 0; i < N; i++) (ans += A.at(i) * M) %= K;
    for (int i = 0; i < M; i++) (ans += B.at(i) * N) %= K;
  } else {
    long a = accumulate(A.begin(), A.end(), 0L) % K;
    long b = accumulate(B.begin(), B.end(), 0L) % K;
    ans = a * b % K;
  }
  cout << ans << "\n";
}
0