标签:
题目链接:
Time Limit: 8000/4000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <bits/stdc++.h> #include <stack> using namespace std; #define For(i,j,n) for(int i=j;i<=n;i++) #define mst(ss,b) memset(ss,b,sizeof(ss)); typedef long long LL; template<class T> void read(T&num) { char CH; bool F=false; for(CH=getchar();CH<‘0‘||CH>‘9‘;F= CH==‘-‘,CH=getchar()); for(num=0;CH>=‘0‘&&CH<=‘9‘;num=num*10+CH-‘0‘,CH=getchar()); F && (num=-num); } int stk[70], tp; template<class T> inline void print(T p) { if(!p) { puts("0"); return; } while(p) stk[++ tp] = p%10, p/=10; while(tp) putchar(stk[tp--] + ‘0‘); putchar(‘\n‘); } const LL mod=1e9+7; const double PI=acos(-1.0); const int inf=1e9; const int N=1e5+10; const int maxn=500+10; const double eps=1e-9; int n,vis[1010]; LL fx,fy,f[1010]; struct node { double ang; LL x,y; }po[1010],temp[1010]; int cmp1(node a,node b) { return a.ang<b.ang; } int cmp(node a,node b) { if(a.y==b.y)return a.x<b.x; return a.y<b.y; } int main() { int t; read(t); f[0]=1; For(i,1,1008) { f[i]=f[i-1]*2%mod; } while(t--) { read(n); For(i,1,n) { read(po[i].x);read(po[i].y); } sort(po+1,po+n+1,cmp); LL ans=0; For(i,1,n-1) { int cnt=0,s=0; For(j,i+1,n) { if(po[j].x==po[i].x&&po[j].y==po[i].y){s++;continue;} temp[++cnt].ang=atan2(po[j].y-po[i].y,po[j].x-po[i].x); temp[cnt].x=po[j].x; temp[cnt].y=po[j].y; } sort(temp+1,temp+cnt+1,cmp1); fx=po[i].x,fy=po[i].y; int d=0; for(int j=1;j<=cnt;) { int k,num=s+1; for(k=j+1;k<=cnt;k++) { if((temp[k].y-fy)*(temp[j].x-fx)!=(temp[j].y-fy)*(temp[k].x-fx))break; num++; } j=k; ans=(ans+f[num]-1+mod)%mod; d++; } ans=(ans-(LL)(d-1)*(f[s]-1+mod)%mod+mod)%mod; } cout<<ans<<endl; } return 0; }
标签:
原文地址:http://www.cnblogs.com/zhangchengc919/p/5693133.html