HDU6055 Regular polygon(2017多校第二场)
Regular polygon
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1087 Accepted Submission(s): 405
4 0 0 0 1 1 0 1 1 6 0 0 0 1 1 0 1 1 2 0 2 1
1 2
#include <iostream> #include <cstring>using namespace std;
int n,ans,a,b;
bool mapc[205][205];
struct point
{
int x,y;
};int judge(point a,point b)
{
int x1 = a.x, y1 = a.y, x2 = b.x, y2 = b.y;
int res = 0;
int x3 = -y2+y1+x1 ,y3 = x2-x1+y1;
int x4 = x3-x1+x2 ,y4 = y3-y1+y2;
int x5 = 2x1-x3 ,y5 = 2y1-y3;
int x6 = 2x2-x4 ,y6 = 2y2-y4;
if( (x3<=100 && x3>=-100) && (y3<=100 && y3>=-100)
&& (x4<=100 && x4>=-100) && (y4<=100 && y4>=-100)
&& mapc[x3+100][y3+100] && mapc[x4+100][y4+100] )
res++;
if( (x5<=100 && x5>=-100) && (y5<=100 && y5>=-100)
&& (x6<=100 && x6>=-100) && (y6<=100 && y6>=-100)
&& mapc[x5+100][y5+100] && mapc[x6+100][y6+100] )
res++;
return res;
}point p[505];
int main()
{
while(cin>>n)
{
ans=0;
memset(mapc,0,sizeof(mapc));
for(int i=0;i<n;i++)
{
cin>>a>>b;
p[i].x=a,p[i].y=b;
mapc[a+100][b+100]=1;
}
for(int i=0;i<n;i++)
for(int j=i+1;j<n;j++)
ans+=judge(p[i],p[j]);
cout<<ans/4<<endl;
}return 0;}
.5kkdqdezd7g0.png)
