結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー ngtkanangtkana
提出日時 2020-04-10 20:39:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,008 bytes
コンパイル時間 5,848 ms
コンパイル使用メモリ 214,364 KB
実行使用メモリ 17,028 KB
最終ジャッジ日時 2023-10-13 17:05:42
合計ジャッジ時間 12,284 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 36 ms
7,536 KB
testcase_11 AC 18 ms
4,348 KB
testcase_12 TLE -
testcase_13 AC 13 ms
4,348 KB
testcase_14 AC 30 ms
4,348 KB
testcase_15 AC 16 ms
4,352 KB
testcase_16 AC 47 ms
8,584 KB
testcase_17 AC 14 ms
4,348 KB
testcase_18 TLE -
testcase_19 AC 1,235 ms
4,352 KB
testcase_20 AC 156 ms
17,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,m,k;std::cin>>n>>m>>k;
    char c;std::cin>>c;
    std::vector<lint>a(n),b(m);
    for(lint&y:b)std::cin>>y;
    for(lint&x:a)std::cin>>x;
    lint ans=0;
    if(c=='+'){
        std::map<lint,lint>map;
        for(lint y:b)map[y%k]++;
        for(lint x:a){
            x%=k;
            ans+=map[x?k-x:0];
        }
    }else{
        std::set<lint>set;
        for(lint i=1;i*i<=k;i++){
            if(k%i)continue;
            set.insert(i);
            if(i*i!=k)set.insert(k/i);
        }
        std::map<lint,lint>map;
        for(lint y:b){
            for(lint d:set){
                if(!(y%d))map[d]++;
            }
        }
        for(lint x:a){
            ans+=map[k/std::gcd(k,x)];
        }
    }
    std::cout<<ans<<'\n';
}
0