HDU6055——多校2017
来源:互联网 发布:商城数据统计公式 编辑:程序博客网 时间:2024/06/05 17:23
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6055
Regular polygon
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2777 Accepted Submission(s): 1110
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
40 00 11 01 160 00 11 01 12 02 1
Sample Output
12
Source
2017 Multi-University Training Contest - Team 2
Recommend
liuyiding
题意:在二维平面内有N个点,判断这n个点能组成多少个正多边形
思路:开始也很懵,不过后来知道坐标是整数点的正多边形只有正方形之后,思路清晰了很多。
贴上一份当时队友的代码:
#include<iostream>#include<sstream>#include<fstream>#include<set>#include<map>#include<cmath>#include<queue>#include<stack>#include<vector>#include<cstdio>#include<string>#include<cstring>#include<algorithm>using namespace std;#define si(x) scanf("%d", &x)#define sii(x,y) scanf("%d %d", &x, &y)#define sl(x) scanf("%ld", &x)#define sll(x,y) scanf("%ld %ld", &x, &y)#define fe1(i, a, b) for(int i = a; i <= b; i++)#define fu(i, a, b) for(int i = a; i < b; i++)#define MP(x, y) make_pair(x, y)typedef pair<int , int> pii;typedef long long LL;typedef unsigned long long LLu;const int maxn = 33;const int inf = 0x3f3f3f3f;using namespace std ;#define eqs 1e-9struct node{ double x , y ;}p[1100] ;bool cmp(node a,node b){ return ( a.x < b.x || ( a.x == b.x && a.y < b.y ) ) ;}bool judge(double x,double y,int n){ int low = 0 , mid , high = n-1 ; while( low <= high ) { mid = (low + high) / 2 ; if( fabs(p[mid].x-x) < eqs && fabs(p[mid].y-y) < eqs ) return true ; else if( p[mid].x-x > eqs || ( fabs(p[mid].x-x) < eqs && p[mid].y-y > eqs ) ) high = mid - 1 ; else low = mid + 1 ; } return false ;}int main(){ int n , i , j , num ; double x , y , xx , yy ; while(~scanf("%d", &n)) { num = 0 ; for(i = 0 ; i < n ; i++) { scanf("%lf %lf", &p[i].x, &p[i].y) ; } sort(p,p+n,cmp) ; for(i = 0 ; i < n ; i++) { for(j = i+1 ; j < n ; j++) { if( i == j ) continue ; x = (p[i].x+p[j].x)/2 ; y = (p[i].y+p[j].y)/2 ; xx = p[i].x - x ; yy = p[i].y - y ; if( judge(x+yy,y-xx,n) && judge(x-yy,y+xx,n) ) { num++ ; } } } printf("%d\n", num/2) ; } return 0;}
阅读全文
0 0
- HDU6055——多校2017
- hdu6055
- hdu6055—Regular polygon(正方形的判定)
- [结论题+枚举] HDU6055:[2017 多校-第2场] Regular polygon
- HDU6055 2017 Multi-University Training Contest
- Hdu6055 Regular polygon(2017多校第2场)
- HDU6055 Regular polygon(2017多校第二场)
- HDU6055 Regular polygon 2017 Multi-University Training Contest
- 2017多校训练Contest2: 1011 Regular polygon hdu6055
- 2017杭电多校联赛第二场-Regular polygon (hdu6055)判断点集能构成多少个正方形
- HDU6055 Regular polygon(计算几何,2017 HDU多校联赛 第2场)
- hdu6055 Regular polygon 2017多校联盟2 11题 -枚举
- 2017多校训练第二场 hdu6055 Regular polygon (几何+暴力)
- HDU6055 Regular polygon【哈希】
- HDU6055(数学题寻找正多边形)
- HDU6055-Regular polygon
- HDU6055(Regular polygon)
- HDU6055-Regular polygon
- 论文解析:基于深度卷积神经网络的城市遥感图像小物体语义分割及不确定性建模
- auto, register, static分析
- 安装Google protobuf
- 改变浏览器位置
- WOJ1143-Part-time Job
- HDU6055——多校2017
- hibernate--事物机制(面试)
- 强大的滚动控件RecyclerView
- 群赛2总结-----2017.9.4
- java基础面试题
- Android Studio SVN使用
- python--两个list 求交\并\差集
- 找出数组中第一个重复的元素
- Centos7免密登陆配置