标签:.com ber width block struct scan next case tput
1 #include<cstdio> 2 #include<iostream> 3 #include<cmath> 4 #include<algorithm> 5 #include<string.h> 6 using namespace std; 7 8 bool vis[205][205]; 9 //把所有值都加100 10 11 struct node 12 { 13 int x,y; 14 }point[505]; 15 16 bool cmp(node a,node b) 17 { 18 return a.x<b.x; 19 } 20 21 bool judge(node c) 22 { 23 if(c.x>=0&&c.x<=200&&c.y>=0&&c.y<=200) 24 if(vis[c.x][c.y]) 25 return true; 26 return false; 27 } 28 29 30 int main() 31 { 32 int n,cnt; 33 while(~scanf("%d",&n)) 34 { 35 memset(vis,false,sizeof(vis)); 36 for(int i=0;i<n;i++) 37 { 38 scanf("%d%d",&point[i].x,&point[i].y); 39 point[i].x+=100; 40 point[i].y+=100; 41 vis[point[i].x][point[i].y]=true; 42 } 43 sort(point,point+n,cmp); 44 cnt=0; 45 node a,b,c,d; 46 int disx,disy; 47 for(int i=0;i<n;i++) 48 { 49 for(int j=i+1;j<n;j++) 50 { 51 a=point[i]; 52 b=point[j]; 53 disx=abs(a.y-b.y); 54 disy=abs(a.x-b.x); 55 if(b.y<=a.y) 56 { 57 //右上 58 c.x=b.x+disx; 59 c.y=b.y+disy; 60 d.x=a.x+disx; 61 d.y=a.y+disy; 62 if(judge(c)&&judge(d)) 63 cnt++; 64 //左下 65 c.x=b.x-disx; 66 c.y=b.y-disy; 67 d.x=a.x-disx; 68 d.y=a.y-disy; 69 if(judge(c)&&judge(d)) 70 cnt++; 71 } 72 else 73 { 74 //右下 75 c.x=b.x+disx; 76 c.y=b.y-disy; 77 d.x=a.x+disx; 78 d.y=a.y-disy; 79 if(judge(c)&&judge(d)) 80 cnt++; 81 //左上 82 c.x=b.x-disx; 83 c.y=b.y+disy; 84 d.x=a.x-disx; 85 d.y=a.y+disy; 86 if(judge(c)&&judge(d)) 87 cnt++; 88 } 89 } 90 } 91 printf("%d\n",cnt/4); 92 } 93 return 0; 94 }
HDU 6055 17多校 Regular polygon(计算几何)
标签:.com ber width block struct scan next case tput
原文地址:http://www.cnblogs.com/Annetree/p/7249775.html