11619 - pC - Collinear
raw download clone
C
views 19
,
size 1462 b
#include <stdio.h>

int max(int a, int b);

int main(void)
{
    int t, n, temp, maximum, ans;
    int x[101], y[101], coline[101];

    scanf("%d", &t);
    for(int i=1; i<=t; i++)
    {
        ans = 0;
        maximum = 0;
        for(int p=1; p<=101; p++)
            coline[p] = 0;
        scanf("%d", &n);
        for(int j=1; j<=n; j++)
            scanf("%d%d", &x[j], &y[j]);
        for(int k=1; k<=n-1; k++)
        {
            for(int l=k+1; l<=n; l++)
            {
                temp = 2;
                if(x[k] == x[l])
                {
                    for(int m=1; m<=n; m++)
                    {
                        if(m != k && m != l && x[m] == x[k])
                            temp++;
                    }
                }
                else
                {
                    for(int m=1; m<=n; m++)
                    {
                        if(m != k && m != l && (x[l] - x[k]) * (y[m] - y[l]) == (x[m] - x[l]) * (y[l] - y[k]))
                            temp++;
                    }
                }
                maximum = max(maximum, temp);
                coline[temp]++;
            }
        }
        for(int o=3; o<=maximum; o++)
        {
            ans += (coline[o] * 2 / o) / (o - 1);
        }
        printf("%d\n", ans);
    }

    return 0;
}

int max(int a, int b)
{
    if(a > b)
        return a;
    else
        return b;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.