結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー Y17Y17
提出日時 2020-02-14 23:00:14
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,027 bytes
コンパイル時間 2,116 ms
コンパイル使用メモリ 167,216 KB
実行使用メモリ 17,408 KB
最終ジャッジ日時 2024-04-27 20:06:24
合計ジャッジ時間 8,225 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,816 KB
testcase_01 AC 3 ms
6,940 KB
testcase_02 AC 3 ms
6,940 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 3 ms
6,944 KB
testcase_05 AC 3 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 3 ms
6,944 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 62 ms
8,576 KB
testcase_11 AC 43 ms
6,940 KB
testcase_12 TLE -
testcase_13 AC 30 ms
6,940 KB
testcase_14 AC 60 ms
6,940 KB
testcase_15 AC 35 ms
6,940 KB
testcase_16 AC 72 ms
9,600 KB
testcase_17 AC 28 ms
6,940 KB
testcase_18 TLE -
testcase_19 AC 419 ms
6,940 KB
testcase_20 AC 220 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];
            if(a[i] % k == 0){
                ans += m;
            }else{
                for(auto p : bmp){
                    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