题解 P7918 [Kubic] Lines
Origin0107 · · 题解
update on 11.12:将 double 换为 long double 减小精度造成的误差,感谢 @yzy1 指出错误。
Problem
给定
Solution
- 易证
n 条直线两两相交时,需要n-1 条直线去覆盖。 - 当有
i 条直线相互平行时,这i 条直线可以视作1 条直线
记
Code
#include<bits/stdc++.h>
using namespace std;
map<long double,int> m;
long double a,b,c;
int x,n;
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a>>b>>c;
m[b/a]++;
x=max(x,m[b/a]);
}
cout<<n-x<<endl;
return 0;
}