本来代码在本地跑的好好的,结果一交洛谷全部RE,在在线IDE中只要开O2就运行错误,求dalao指正
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
int n;
struct node{
int fm;int fz;
}a[100001];
void check(int d){
if(a[d].fm <0&&a[d].fz <0){
a[d].fm *=-1;
a[d].fz *=-1;
return ;
}
if(a[d].fm <0){
a[d].fm *=-1;
a[d].fz *=-1;
return ;
}
}
int gcd(int a,int b){
int r=a%b;
if(a%b==0) return b;
else gcd(b,r);
}
bool comp(node x,node y){
if(x.fm!=y.fm) return x.fm <y.fm ;
return x.fz <y.fz ;
}
int main(){
int temp;
cin >> n;
for(int i=1;i<=n;i++){
cin >> a[i].fz >> a[i].fm >> temp;
check(i);
int p=gcd(a[i].fz,a[i].fm);
a[i].fz /= p;
a[i].fm /= p;
}
sort(a+1,a+n+1,comp);
int max=0,k=0;
//cout << a[1].fz << "/" << a[1].fm << endl;
for(int i=1;i<=n;i++){
if(i==1){
k++;
continue;
}
if(a[i].fm != a[i-1].fm || a[i].fz != a[i-1].fz){
if(k>max) max=k;
k=1;
}
else k++;
//cout << a[i].fz << "/" << a[i].fm << endl;
}
if(max<k) max=k;
cout << n-max << endl;
return 0;
}