标签:++ 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