結果
| 問題 |
No.990 N×Mマス計算(Kの倍数)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-30 21:39:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,041 bytes |
| コンパイル時間 | 1,499 ms |
| コンパイル使用メモリ | 177,332 KB |
| 実行使用メモリ | 17,280 KB |
| 最終ジャッジ日時 | 2024-06-23 04:01:48 |
| 合計ジャッジ時間 | 7,703 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 TLE * 1 |
ソースコード
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n,m,k;
std::cin >> n>>m>>k;
char op;
std::cin >> op;
vector<ll> a(n),b(m);
for (int i = 0; i < m; i++) {
std::cin >> b[i];
}
for (int i = 0; i < n; i++) {
std::cin >> a[i];
}
if(op=='+'){
map<ll,ll> cnt;
for (int i = 0; i < n; i++) {
cnt[(k-a[i]%k)%k]++;
}
ll ans = 0;
for (int i = 0; i < m; i++) {
ans += cnt[b[i]%k];
}
std::cout << ans << std::endl;
}else{
ll ans = 0;
map<ll,ll> cnt;
for (int i = 0; i < n; i++) {
ll g = __gcd(k,a[i]);
cnt[k/g]++;
}
for (int i = 0; i < m; i++) {
for (auto e : cnt) {
if(b[i]%e.first==0){
ans+=e.second;
}
}
}
std::cout << ans << std::endl;
}
}