結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー ninoinuininoinui
提出日時 2020-02-16 03:37:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 618 bytes
コンパイル時間 1,448 ms
コンパイル使用メモリ 176,504 KB
実行使用メモリ 17,152 KB
最終ジャッジ日時 2024-04-27 20:54:57
合計ジャッジ時間 2,997 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 48 ms
7,680 KB
testcase_11 AC 38 ms
6,940 KB
testcase_12 AC 142 ms
6,944 KB
testcase_13 AC 24 ms
6,940 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 60 ms
8,704 KB
testcase_17 WA -
testcase_18 AC 142 ms
6,944 KB
testcase_19 AC 50 ms
6,944 KB
testcase_20 AC 172 ms
17,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

  long ans = 0;
  if (op == '+') {
    map<long, long> MA;
    for (long a : A) MA[a % K]++;
    for (long b : B) ans += MA[K - b % K];
  } else {
    map<long, long> MA1, MA2;
    for (long a : A) MA1[__gcd(a, K)]++;
    for (long b : B) MA2[__gcd(b, K)]++;
    for (auto ma1 : MA1)
      for (auto ma2 : MA2)
        if (ma1.first * ma2.first % K == 0) ans += ma1.second * ma2.second;
  }
  cout << ans << "\n";
}
0