版权声明:版权声明,使用请说明出处 https://blog.csdn.net/qq_41835683/article/details/88959041
题意题解都在代码里..
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=2e5+5;
int a[maxn],b[maxn];
map<long double,int>mp;
signed main(){
/*
You want to create a new array c as follows: choose some real (i.e. not necessarily integer) number d, and then for every i∈[1,n] let ci:=d⋅ai+bi.
Print one integer — the maximum number of zeroes in array c, if you choose d optimally.
*/
int n;cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=n;i++)cin>>b[i];
int ans=0;
for(int i=1;i<=n;i++){
if(a[i]==0&&b[i]==0)ans++;//for 0 0
else if(!a[i]&&b[i])continue;//for 0 x(x!=0)
else mp[-(long double)b[i]/a[i]]++;//for every Situation
}
int res=0;
for(auto it:mp)res=max(res,it.second);//for the max
cout<<ans+res<<endl;
return 0;
}