枚举两点,算一下斜率 sort一遍 判个重 输出解
25行 搞定…//By SiriusRen#include#include #include using namespace std;int n,top,ans;double x[205],y[205],s[40005],temp;int main(){ scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%lf%lf",&x[i],&y[i]); for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(i==j)continue; temp=(x[i]-x[j])/(y[i]-y[j]); if(fabs(temp)>0x7fffffff)temp=0x7fffffff; s[++top]=temp; } } sort(s+1,s+1+top),temp=0; for(int i=1;i<=top;i++){ if(fabs(s[i]-temp)>1e-9)ans++,temp=s[i]; } printf("%d\n",ans);}