結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー Y17Y17
提出日時 2020-02-14 22:49:02
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 961 bytes
コンパイル時間 1,223 ms
コンパイル使用メモリ 167,236 KB
実行使用メモリ 17,408 KB
最終ジャッジ日時 2024-04-27 20:00:31
合計ジャッジ時間 4,614 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 3 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 49 ms
8,704 KB
testcase_11 AC 37 ms
6,940 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 51 ms
6,944 KB
testcase_15 AC 30 ms
6,940 KB
testcase_16 AC 59 ms
9,600 KB
testcase_17 AC 23 ms
6,940 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 159 ms
17,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define int long long

signed main(){
    int n, m, k;
    cin >> n >> m >> k;
    char op;
    cin >> op;

    int a[100010];
    int b[100010];
    map<int, int> bmp;
    int ans = 0;

    if(op == '*'){
        for(int i = 0;i < m;i++){
            cin >> b[i];
            int tmp = __gcd(b[i], k);
            bmp[k/tmp]++;
        }

        for(int i = 0;i < n;i++){
            cin >> a[i];
            for(auto p : bmp){
                if(p.first * p.first > a[i]) break;
                if(a[i] % p.first == 0){
                    ans += p.second;
                }
            }
        }
    }else{

        for(int i = 0;i < m;i++){
            cin >> b[i];
            b[i] %= k;
            bmp[b[i]]++;
        }

        for(int i = 0;i < n;i++){
            cin >> a[i];
            a[i] %= k;
            ans += bmp[(k-a[i]) % k ];
        }
    }

    cout << ans << endl; 


    return 0;
}
0