hdu 5738

来源:互联网 发布:眼睛很亮女孩子知乎 编辑:程序博客网 时间:2024/06/09 20:11
#include <cmath>#include <cstdio>#include <cstring>#include <algorithm>#include <math.h>#include <iostream>#define ll long long#define mod 1000000007using namespace std;int n,maxx;double s[10005];struct line{    ll x,y;} a[10005];bool cmp(line a,line b){    return a.x<b.x;}ll pw[10100];void init(){    pw[0]=1;    for (int i=1;i<=10000;i++)        pw[i]=2*pw[i-1] % mod;}int main(){    long long res;    int T;    init();    scanf("%d",&T);    while(T--)    {        scanf("%d",&n);        res=0;        for(int i=1; i<=n; i++)            scanf("%lld%lld",&a[i].x,&a[i].y);        sort(a+1,a+1+n,cmp);        for(int i=1; i<n; i++)        {            int tot=1,ans=0;            int c=0;            for(int j=i+1; j<=n; j++)            {                if (a[i].x==a[j].x && a[i].y == a[j].y) c++;                else                {                if (a[i].x==a[j].x) s[tot++]=1e9+7;                else                    s[tot++]=(1.0*a[j].y-1.0*a[i].y)/(1.0*a[j].x-1.0*a[i].x);                }            }            ll cnum=0;            sort(s+1,s+tot);            for(int i=1; i<tot-1; i++)                if(fabs(s[i+1]-s[i])<1e-12)                    ans++;                else                {                    //res+= (1LL<<(ans+1+c)) -1;                    res+= pw[ans+1+c] -1 + mod ;                    res%=mod;                    ans=0;                    cnum++;                }            if (tot>1)            {                //res+= (1LL<<(ans+1+c)) -1;                    res+= pw[ans+1+c] -1 + mod ;                    res%=mod;                    cnum++;                    res-=(cnum-1)*(pw[c] -1 );                   res%=mod;            }            if (tot==1)            {                //res+= (1LL<<c) -1 ;                res+=pw[c] - 1 + mod ;                res %= mod;            }        }        printf("%lld\n",res);    }    return 0;}
0 0