说起来你可能不信……这题我断断续续写了两天
本来,如果没有重(chong)点,就是一道水题。
但是加上重点,就是一道有毒的题。
思路真不想说了……网上也有很多,虽然我都看不懂……
ps0:这题A完之后才搜的题解
ps1:C(k , 1)+C( k , 2)+C( k , 3)+...+C( k , k) = 2 ^ k-1;相当于k个位置,每个位置选或不选,至少选一个,一共有多少种选法?
【代码】(原生态)
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
#define REPP(i,k,n) for(int i=k;i<=n;i++)
#define scan(d) scanf("%d",&d)
#define scann(n,m) scanf("%d%d",&n,&m)
#define mst(a,k) memset(a,k,sizeof(a));
#define LL long long
#define maxn 1005
/*
inline int read()
{
int s=0;
char ch=getchar();
for(; ch<'0'||ch>'9'; ch=getchar());
for(; ch>='0'&&ch<='9'; ch=getchar())s=s*10+ch-'0';
return s;
}
inline void print(int x)
{
if(!x)return;
print(x/10);
putchar(x%10+'0');
}
*/
const int mod = 1000000007;
struct node
{
int x,y;
}p[maxn];
bool cmp(node a,node b)
{
return a.x<b.x || a.x==b.x && a.y<b.y;
}
double xielv(int i,int j)
{
if(p[i].x==p[j].x)
return 10000000000+1;
return (p[j].y-p[i].y)*1.0/(p[j].x-p[i].x);
}
double xl[maxn];
int C[maxn+1][maxn+1];
void Initial()
{
int i,j;
for(i=0; i<=maxn; ++i)
{
C[0][i] = 0;
C[i][0] = 1;
}
for(i=1; i<=maxn; ++i)
for(j=1; j<=maxn; ++j)
C[i][j] = (C[i-1][j] + C[i-1][j-1]) % mod;
}
int main()
{
//freopen("1005.in","r",stdin);
//freopen("out.txt","w",stdout);
Initial();
int n,t,j,cd,k;
scan(t);
while(t--)
{
scan(n);
REPP(i,1,n) scann(p[i].x,p[i].y);
sort(p+1,p+1+n,cmp);
LL ans=0,temp=0;
for(int i=1;i<=n;i++)
{
k=1;cd=1;
for(j=i+1;j<=n;j++)
{
if(p[i].x==p[j].x && p[i].y==p[j].y)
{
cd++;i++;
continue;
}
xl[k++]=xielv(i,j);
//printf("(%d %d) (%d %d) %lf\n",p[i].x,p[i].y,p[j].x,p[j].y,xl[k-1]);
}
sort(xl+1,xl+k);
int cnt=1;
temp=0;
//for(j=1;j<k;j++) printf("%lf\n",xl[j]);
xl[k]=xl[k-1]+1;
for(j=2;j<=k;j++)
{
if(xl[j]==xl[j-1])
{
cnt++;
}
else
{
LL t=0;
for(int l=1;l<=cnt;l++)
t = (t + C[cnt][l]) % mod;
temp = (temp+t) % mod;
//printf("%d\n",cnt);
cnt=1;
}
}
//printf("cd=%d %d %I64d\n",cd,i,temp);
if(cd>1)
{
// temp = temp*(cd-1) % mod;
LL t=0;
for(j=2;j<=cd;j++)
{
t = (t + C[cd][j]) % mod;
}
temp = (temp + (t+cd-1)*temp + t) % mod;
//printf("%lld\n",temp);
}
ans = (ans+temp) % mod;
}
printf("%I64d\n",ans);
}
return 0;
}