bzoj 1610: [Usaco2008 Feb]Line connection game【Mumbling】

The gutter capsized.jpg
Actually forgot to divide by 0.
Enumerate the lines between two and two, and put the slopes in order and remove the heavy ones.
What a night of water

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=205;
int n,tot,ans;
double x[N],y[N],a[N*N];
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=i+1;j<=n;j++)
        {
            if(y[i]==y[j])
                a[++tot]=1e9;
            else
                a[++tot]=(x[i]-x[j])/(y[i]-y[j]);
        }
    sort(a+1,a+1+tot);
    for(int i=1;i<=tot;i++)
        if(i==1||a[i]!=a[i-1])
            ans++;
    printf("%d\n",ans);
    return 0;
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324785836&siteId=291194637