#include<stdio.h> #include<iostream> #include<algorithm> #include<stdlib.h> #include<map> #define LL long long using namespace std; double x[2010],y[2010]; struct s { double x,y; }a[1010*1010]; int cmp(s a, s b) { if(a.x==b.x) return a.y<b.y; return a.x<b.x; } LL C(LL a,LL b) { LL ans=1; LL i; while(b>a/2) b=a-b; for(i=1;i<=b;i++) { ans*=(a-i+1); ans/=i; } return ans; } int main() { int t,c=0; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); int i,j; for(i=1;i<=n;i++) { //double x,y; scanf("%lf%lf",&x[i],&y[i]); } int k=0; for(i=1;i<=n;i++) for(j=i+1;j<=n;j++) { if(x[i]==x[j]&&y[i]==y[j]) continue; double mx,my; mx=(x[i]+x[j])/2; my=(y[i]+y[j])/2; a[k].x=mx; a[k++].y=my; } sort(a,a+k,cmp); /*for(i=0;i<k;i++) { printf("****%lf %lf\n",a[i].x,a[i].y); }*/ double tx,ty; LL temp=1,ans=0; for(i=1;i<k;i++) { if(a[i].x==a[i-1].x&&a[i].y==a[i-1].y) { temp++; } else { if(temp<2) { temp=1; continue; } ans+=C(temp,2); temp=1; } } if(temp>=2) ans+=C(temp,2); printf("Case %d: %lld\n",++c,ans); } } |
Double click to view unformatted code.