結果
問題 | No.990 N×Mマス計算(Kの倍数) |
ユーザー |
![]() |
提出日時 | 2020-02-14 22:41:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 798 bytes |
コンパイル時間 | 1,803 ms |
コンパイル使用メモリ | 174,364 KB |
実行使用メモリ | 19,364 KB |
最終ジャッジ日時 | 2024-11-16 01:03:45 |
合計ジャッジ時間 | 12,104 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 16 TLE * 3 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m, k; cin >> n >> m >> k; char op; cin >> op; map<int, int> mp1, mp2; for (int i = 0; i < m; ++i) { int b; cin >> b; if (op == '*') ++mp1[__gcd(b, k)]; else ++mp1[b % k]; } for (int i = 0; i < n; ++i) { int a; cin >> a; if (op == '*') ++mp2[__gcd(a, k)]; else ++mp2[a % k]; } long long ans = 0; for (auto itr1 : mp1) { for (auto itr2 : mp2) { if (op == '+') { if ((itr1.first + itr2.first) % k == 0) ans += 1LL * itr1.second * itr2.second; } else { if (1LL * itr1.first * itr2.first % k == 0) ans += 1LL * itr1.second * itr2.second; } } } cout << ans << '\n'; return 0; }