【HDU 6055 Regular polygon】+ map
2017-07-27 17:28
302 查看
Regular polygon
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 42 Accepted Submission(s): 13
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 the points’ 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
Source
2017 Multi-University Training Contest - Team 2
思路 : 暴力两个点,map 判断剩下两个点是否存在
AC代码:
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 42 Accepted Submission(s): 13
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 the points’ 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
Source
2017 Multi-University Training Contest - Team 2
思路 : 暴力两个点,map 判断剩下两个点是否存在
AC代码:
#include "cstdio" #include "map" #include "cstring" using namespace std; struct Point{ int x,y; }point[510]; int Map[700][700]; int main(){ int n; while(~scanf("%d",&n)){ memset(Map, 0, sizeof(Map)); for(int i=1;i<=n;i++){ scanf("%d %d",&point[i].x,&point[i].y); Map[point[i].x+300][point[i].y+300]=1; } int ans=0; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(i==j) continue; double a = point[i].x,b = point[i].y; double c = point[j].x,d = point[j].y; double xi1= (a+b+c-d)/2.0; double yi1= (-a+b+c+d)/2.0; double xi2= (a-b+c+d)/2.0; double yi2= (a+b-c+d)/2.0; int x1 = xi1,y1=yi1,x2=xi2,y2=yi2; if(Map[x1+300][y1+300]&&Map[x2+300][y2+300]&&x1==xi1&&y1==yi1&&x2==xi2&&y2==yi2){ ans++; } } } printf("%d\n",ans/4); } return 0; }
相关文章推荐
- HDU 2017 多校联合训练赛2 1011 6055 Regular polygon map&pair
- 【2017多校第二场】HDU 6055 Regular polygon【几何,枚举】
- HDU-6055 Regular polygon
- hdu 6055 Regular polygon(判断正方形)(2017 Multi-University Training Contest - Team 2)
- (2017多校2)1011/hdu-6055 Regular polygon(计算几何)
- hdu 6055 Regular polygon
- 【几何】hdu 6055 Regular polygon
- HDU 6055 Regular polygon
- hdu 6055 Regular polygon(判断正方形)(2017 Multi-University Training Contest - Team 2)
- hdu 6055 Regular polygon(判断正方形)(2017 Multi-University Training Contest - Team 2)
- HDU 6055 Regular polygon(几何数学)(多校2)
- HDU 6055 Regular polygon
- [HDU]-6055 Regular polygon
- hdu 6055 Regular polygon(判断正方形)(2017 Multi-University Training Contest - Team 2)
- hdu 6055 Regular polygon(判断正方形)(2017 Multi-University Training Contest - Team 2)
- hdu 6055 Regular polygon(判断正方形)(2017 Multi-University Training Contest - Team 2)
- HDU 6055 Regular polygon (找正方形)
- HDU 6055 Regular polygon(几何)
- Regular polygon - HDU 6055 - 2017 多校
- hdu 6055 Regular polygon(判断正方形)(2017 Multi-University Training Contest - Team 2)