标签:
#include<cstdio> #include<iostream> #include<map> #include<cmath> #include<algorithm> #define fi first #define se second using namespace std; typedef long long LL; const int MOD=1e9+7; struct point { LL x,y; bool operator == (const point &t)const { return x==t.x&&y==t.y; } bool operator < (const point &t)const { return x==t.x?y<t.y:x<t.x; } }p[1005]; map<pair<LL,LL>,int>f; LL gcd(LL a,LL b) { return b==0?a:gcd(b,a%b); } pair<LL,LL> get_slope(point a,point b) { LL up=b.y-a.y; LL dw=b.x-a.x; LL t=gcd(up,dw); up/=t,dw/=t; return make_pair(up,dw); } LL quick_mod(int a,int b) { LL res=1,t=a; while(b) { if(b&1)res=(res*t)%MOD; t=(t*t)%MOD; b>>=1; } return res; } int main() { int T; scanf("%d",&T); while(T--) { int n; scanf("%d",&n); LL ans=0; for(int i=0;i<n;i++) scanf("%lld%lld",&p[i].x,&p[i].y); sort(p,p+n); for(int i=0;i<n;i++) { f.clear(); int res=0; for(int j=i+1;j<n;j++) { if(p[i]==p[j])res++; else f[get_slope(p[i],p[j])]++; } (ans+=quick_mod(2,res)-1)%=MOD; for(map<pair<LL,LL>,int>::iterator iter=f.begin();iter!=f.end();iter++) (ans+=quick_mod(2,res)*(quick_mod(2,iter->se)-1))%=MOD; } printf("%lld\n",ans); } } /* 1 6 -1 -1 1 -1 -1 1 1 1 0 0 0 0 25 */
标签:
原文地址:http://www.cnblogs.com/homura/p/5696049.html