HDU 6055 Regular polygon
2017-07-28 15:43
302 查看
Regular polygon
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1529 Accepted Submission(s): 597
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
Recommend liuyiding | We have carefully selected several similar problems for you: 6055 6054 6053 6052 6051
/* * @Author: Lyucheng * @Date: 2017-07-27 14:26:58 * @Last Modified by: Lyucheng * @Last Modified time: 2017-07-28 15:43:15 */ /* 题意:给你一个点阵,让你找多边形的个数,因为点都是整数所以只可能是正方形 */ #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <string> #include <math.h> #include <stdlib.h> #include <time.h> #define MAXN 5005 #define MAXM 2005 #define EXP 1e-6 using namespace std; struct Point{ int x,y; Point(){} Point(int _x,int _y){ x=_x; y=_y; } bool operator < (const Point & other) const{ if(x==other.x) return y<other.y; return x<other.x; } }point[MAXN]; int n; bool vis[MAXM][MAXM]; bool ok(Point a,Point b){//对点 double ax=(a.x+a.y+b.x-b.y)*1.0/2; double ay=(-a.x+a.y+b.x+b.y)*1.0/2; double bx=(a.x-a.y+b.x+b.y)*1.0/2; double by=(a.x+a.y-b.x+b.y)*1.0/2; if(ax-(int)ax>EXP||bx-(int)bx>EXP||ay-(int)ay>EXP||by-(int)by>EXP) return false; if(ax<0||ay<0||bx<0||by<0) return false; if(vis[(int)ax][(int)ay]==true&&vis[(int)bx][(int)by]==true) return true; return false; } inline void init(){ memset(vis,false,sizeof vis); } int main(){ // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); while(scanf("%d",&n)!=EOF){ init(); for(int i=0;i<n;i++){ scanf("%d%d",&point[i].x,&point[i].y); point[i].x+=100; point[i].y+=100; vis[point[i].x][point[i].y]=true; } sort(point,point+n); int res=0; for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ if(ok(point[i],point[j])==true){ res++; } } } printf("%d\n",res/2); } return 0; }
相关文章推荐
- 2017 多校训练第二场 HDU 6055 Regular polygon
- hdu 6055 Regular polygon(判断正方形)(2017 Multi-University Training Contest - Team 2)
- hdu 6055 Regular polygon
- HDU 6055 Regular polygon(几何)
- hdu 6055 Regular polygon(判断正方形)(2017 Multi-University Training Contest - Team 2)
- hdu 6055 Regular polygon
- HDU 6055 Regular polygon(hash)
- hdu 6055 Regular polygon(判断正方形)(2017 Multi-University Training Contest - Team 2)
- HDU 6055 Regular polygon 暴力枚举
- hdu 6055 Regular polygon(判断正方形)(2017 Multi-University Training Contest - Team 2)
- HDU 6055 Regular polygon (计算几何 + 国家队论文结论)
- hdu 6055 Regular polygon(判断正方形)(2017 Multi-University Training Contest - Team 2)
- HDU 6055 Regular polygon【几何】
- HDU-6055 Regular polygon
- HDU 6055 (2017 多校训练赛2 1011)Regular polygon
- Regular polygon(HDU 6055)
- hdu-6055-Regular polygon
- 【2017多校第二场】HDU 6055 Regular polygon【几何,枚举】
- 【HDU 6055 Regular polygon】+ map
- 17 多校 - 2 - 1011 - Regular polygon (HDU - 6055)