結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー %20%20
提出日時 2020-02-05 01:51:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 611 bytes
コンパイル時間 1,780 ms
コンパイル使用メモリ 208,620 KB
実行使用メモリ 12,800 KB
最終ジャッジ日時 2024-04-27 19:26:02
合計ジャッジ時間 4,885 ms
ジャッジサーバーID
(参考情報)
judge3 / 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 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 WA -
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 29 ms
6,940 KB
testcase_11 AC 14 ms
6,940 KB
testcase_12 WA -
testcase_13 AC 10 ms
6,944 KB
testcase_14 AC 27 ms
6,940 KB
testcase_15 AC 14 ms
6,944 KB
testcase_16 AC 39 ms
6,944 KB
testcase_17 AC 14 ms
6,940 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 99 ms
12,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using ll=long long;

int gcd(int a,int b){
	return a?gcd(b%a,a):b;
}

int main(){cin.tie(0);ios::sync_with_stdio(false);
	int N,M,K;cin>>N>>M>>K;
	string op;cin>>op;
	ll z=0;
	if(op=="+"){
		map<int,int>m;
		for(int i=0;i<M;++i){
			int B;cin>>B;
			++m[B%K];
		}
		for(int i=0;i<N;++i){
			int A;cin>>A;
			z+=m[(K-A%K)%K];
		}
	}else{
		map<int,int>m;
		for(int i=0;i<M;++i){
			int B;cin>>B;
			++m[gcd(K,B)];
		}
		for(int i=0;i<N;++i){
			int A;cin>>A;
			for(auto b:m){
				if(A*b.first%K==0){
					z+=b.second;
				}
			}
		}
	}
	cout<<z<<"\n";
	return 0;
}
0