Eureka
Problem Descriptionprofessor Zhang DrawsNPoints on the plane, which is conveniently labeled by1,2,.. . ,n . TheI-th Point was at(xi,yi) . Professor Zhang wants to know, the number of best sets. As the value could be very large, print it modulo9+7 .
A SetP(PContains the label of the points) is called best set if and only if there be at least one best pair inP. Numbersuandv (u,v∈P,u≠v) is called best pair, if for everyw∈P ,f(u,v)≥g(u,v,w) , whereF(U,V)=(Xu−xv) 2+ (yu−yv ) 2−−−−−−−−−−−−−−−−−−√ andG(U,V,W)=f ( U,v ) + F (v ,w ) +f (w, U) 2 .
Inputthere is multiple test cases. The first line of input contains an integerT, indicating the number of test cases. For each test case:
The first line contains an integerN (1≤n≤) -then number of points.
Each of the followingNlines contains, integersxi andyi ( −109≤x i,yi≤ 109 ) /span> --coordinates of the i-th point.
Outputfor each test case, output an integer denoting the answer.
Sample INPUT3 31 11 11 1 30 00 11 0 10 0
Sample Output430
#include <cstdio>#include<iostream>#include<map>#include<cmath>#include<algorithm>#defineFi first#defineSe Secondusing namespaceStd;typedefLong LongLL;Const intmod=1e9+7;structpoint{LL x, y; BOOL operator== (ConstPoint &t)Const { returnx==t.x&&y==T.y; } BOOL operator< (ConstPoint &t)Const { returnx==t.x?y<t.y:x<T.x; }}p[1005];map<pair<ll,ll>,int>F; ll GCD (ll A,ll b) {returnb==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; returnMake_pair (UP,DW);} LL Quick_mod (intAintb) {LL res=1, t=A; while(b) {if(b&1) res= (res*t)%MOD; T= (t*t)%MOD; b>>=1; } returnRes;}intMain () {intT; scanf ("%d",&T); while(t--) { intN; scanf ("%d",&N); LL ans=0; for(intI=0; i<n;i++) scanf ("%lld%lld",&p[i].x,&p[i].y); Sort (p,p+N); for(intI=0; i<n;i++) {f.clear (); intres=0; for(intj=i+1; j<n;j++) { if(P[i]==p[j]) res++; ElseF[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); }}/*16-1 -11-1-1 025*/
HDU 5738 Eureka