码迷,mamicode.com
首页 > 其他好文 > 详细

Codeforces Round #544 (Div. 3) D

时间:2019-03-18 18:22:57      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:++   ble   printf   .com   style   span   force   pac   color   

题目链接:D. Zero Quantity Maximization

#include <bits/stdc++.h>
using namespace std;
#define maxn 200005
#define LL long long
#define pii pair<LL,LL>
map<pair<LL,LL>,LL>mp,mpp;
LL a[maxn],b[maxn];
LL gcd(LL a,LL b){
    return b?gcd(b,a%b):a;
}
int main(){
   LL n;
   scanf("%lld",&n);
   for(LL j=0;j<n;j++){
      scanf("%lld",&a[j]);
   }
   for(LL k=0;k<n;k++){
      scanf("%lld",&b[k]);
   }
   LL mx = 0,ans = 0;
   for(LL j=0;j<n;j++){
      LL z = gcd(abs(a[j]),abs(b[j]));
      if(b[j]<0){
         a[j] = -a[j];
         b[j] = -b[j];
      }
      if(a[j]==0){
         if(b[j]==0) ans++;
         continue;
      }
      if(b[j]==0){
           mp[make_pair(1LL*0,1LL*0)]++;
           mx = max(mx, mp[make_pair(1LL*0,1LL*0)]);
           continue;
      }
      mp[make_pair(a[j]/z,b[j]/z)]++;
      mx = max(mx, mp[make_pair(a[j]/z,b[j]/z)]);
   }
   printf("%lld\n",mx+ans);
}

 

Codeforces Round #544 (Div. 3) D

标签:++   ble   printf   .com   style   span   force   pac   color   

原文地址:https://www.cnblogs.com/DyLoder/p/10553803.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!