HDU 2017 多校联赛2 1011 Regular polygon
2017-07-28 17:57
375 查看
Problem Description
On a two-dimensional plane, give you n integer points. Your task is to figure out how many different regular polygon these points can make.
Input
The input file consists of several test cases. Each case the first line is a numbers N (N <= 500). The next N lines ,each line contain two number Xi and Yi(-100 <= xi,yi <= 100), means thepoints’ position.(the data assures no two points share the same position.)
Output
For each case, output a number means how many different regular polygon these points can make.
Sample Input
4 0 0
0 1
1 0
1 1
6
0 0
0 1
1 0
1 1
2 0
2 1
Sample Output
1 2
题目大意:
给一个数n,接下来有n个点,求这些点能组成几个正方形。
c++
#include<cstdio> #include<cstring> #include<iostream> using namespace std; int m[500][500]; struct Point { int x,y; }s[555]; int solve(Point a,Point b) { int x=a.x-b.x; int y=a.y-b.y; int ans=0; if(a.x+y>=0&&a.y-x>=0&&b.x+y>=0&&b.y-x>=0&&m[a.x+y][a.y-x]&&m[b.x+y][b.y-x]) ans++; if(a.x-y>=0&&a.y+x>=0&&b.x-y>=0&&b.y+x>=0&&m[a.x-y][a.y+x]&&m[b.x-y][b.y+x]) ans++; return ans; } int main() { int n,a,b; while(~scanf("%d",&n)) { memset(m,0,sizeof(m)); for(int i=0; i<n; i++) { scanf("%d%d",&a,&b); a+=200; b+=200; s[i].x=a; s[i].y=b; m[a][b]=1; } int ans=0; for(int i=0; i<n; i++) for(int j=i+1; j<n; j++) if(i!=j) ans+=solve(s[i],s[j]); printf("%d\n",ans/4); } }
相关文章推荐
- HDU6170 Two strings(dp,2017 HDU多校联赛 第9场)
- HDU 2017 多校联赛4 1011 Time To Get Up
- HDU6098 Inversion(RMQ,2017 HDU多校联赛 第6场)
- 2017 杭电多校联赛第二场 1001 Is Derek lying? HDU 6045
- 2017 杭电多校联赛第二场 1003 Maximum Sequence(单调队列)HDU 6047
- HDU 2017 多校联赛 1001 Add More Zero
- HDU 2017多校联赛-1012 Balala Power!
- HDU6103 Kirinriki(尺取法,2017 HDU多校联赛 第6场)
- HDU 6053 TrickGCD+6055 Regular polygon【2017多校联赛2】
- HDU 2017多校联赛-Maximum Sequence
- HDU6168 Numbers(模拟,2017 HDU多校联赛 第9场)
- HDU6075 Questionnaire(思路,2017 HDU多校联赛 第4场)
- HDU6034 Balala Power!(贪心,坑!!!)(2017 HDU多校联赛第一场)
- HDU6181 Two Paths(次短路,路径记录,spfa,2017 HDU多校联赛 第10场)
- 2017 杭电多校联赛第二场 1009 TrickGCD(容斥原理) HDU 6053
- HDU6168 Numbers(模拟,2017 HDU多校联赛 第9场)
- HDU6095 Rikka with Competition(水题,2017 HDU多校联赛 第5场)
- HDU6165 FFF at Valentine(深搜dfs,2017 HDU多校联赛 第9场)
- HDU 2017多校联赛-1011 KazaQ's Socks
- HDU6106 Classes(思路,2017 HDU多校联赛 第6场)