結果
| 問題 |
No.990 N×Mマス計算(Kの倍数)
|
| ユーザー |
TsubaMukku
|
| 提出日時 | 2020-02-15 06:55:13 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 131 ms / 2,000 ms |
| コード長 | 670 bytes |
| コンパイル時間 | 1,873 ms |
| コンパイル使用メモリ | 181,672 KB |
| 実行使用メモリ | 12,800 KB |
| 最終ジャッジ日時 | 2024-11-16 02:09:02 |
| 合計ジャッジ時間 | 3,273 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 19 |
ソースコード
#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<ll,ll>ma,mb;
for(int i=0;i<M;++i){
int B;cin>>B;
++mb[gcd(K,B)];
}
for(int i=0;i<N;++i){
int A;cin>>A;
++ma[gcd(K,A)];
}
for(auto a:ma){
for(auto b:mb){
if(a.first*b.first%K==0){
z+=a.second*b.second;
}
}
}
}
cout<<z<<"\n";
return 0;
}
TsubaMukku