hdu6055 Regular polygon 2017多校联盟2 11题 -枚举
来源:互联网 发布:国产电视知乎 编辑:程序博客网 时间:2024/06/05 06:04
Regular polygon
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 455 Accepted Submission(s): 181
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
/*题意:n个点,确定这n个点能组成几个正多边形题解:只有正四边形可以使得所有的顶点为整数点.(具体证明可参考杨景钦在2017的国家队论文)所以正解即求出所有的正四边形个数。枚举2个点,然后暴力判断另外2个点的位置是否存在。最后因为以每个正方形的每一条边为基础找另外两个点,所以每个正方形共计算了4次,ans/=4*/#include <iostream>#include <cstdio>#include <algorithm>#include <string.h>#include <stdlib.h>#include <set>#include <algorithm>#include <vector>#include <queue>using namespace std;const int maxn = 500+10;const int mod = 1e9+7;struct data{ int x; int y;};data a[maxn];bool vis[maxn][maxn];int f(data a,data b){ int cnt = 0; int x = a.x-b.x; int y = a.y-b.y; if(a.x+y>=0 && a.y-x>=0 && b.x+y>=0 && b.y-x>=0 && vis[a.x+y][a.y-x] && vis[b.x+y][b.y-x]) cnt++; if(a.x-y>=0 && a.y+x>=0 && b.x-y>=0 && b.y+x>=0 && vis[a.x-y][a.y+x] && vis[b.x-y][b.y+x]) cnt++; return cnt;}int main(){ int n; while(scanf("%d",&n)!=EOF){ memset(vis,0,sizeof(vis)); for(int i = 0; i<n;++i){ scanf("%d%d",&a[i].x,&a[i].y); a[i].x+=200; a[i].y+=200; vis[a[i].x][a[i].y] = 1; } int ans = 0; for(int i = 0;i<n;++i){ for(int j = i+1;j<n;++j){ ans += f(a[i],a[j]); } } printf("%d\n",ans/4); } return 0;}
阅读全文
1 0
- hdu6055 Regular polygon 2017多校联盟2 11题 -枚举
- [结论题+枚举] HDU6055:[2017 多校-第2场] Regular polygon
- HDU6055 Regular polygon(2017多校第二场)
- HDU6055 Regular polygon(计算几何,2017 HDU多校联赛 第2场)
- HDU6055 Regular polygon +多校联赛第二场
- 2017多校训练Contest2: 1011 Regular polygon hdu6055
- Hdu6055 Regular polygon(2017多校第2场)
- HDU6055 Regular polygon【哈希】
- HDU6055-Regular polygon
- HDU6055(Regular polygon)
- HDU6055-Regular polygon
- hdu6055--Regular polygon
- HDU6055 Regular polygon(思路)
- HDU6055-Regular polygon 简单平面几何
- 2017多校训练第二场 hdu6055 Regular polygon (几何+暴力)
- HDU6055 Regular polygon 2017 Multi-University Training Contest
- hdu6055 Regular polygon【思维+几何基础】
- hdu6055 17多校二1011 Regular polygon
- 多校 ——Balala Power!
- POI--------文件上传导出
- HDU 6047 Maximum Sequence
- CXF Weblogic 报错:Cannot create a secure XMLInputFactory
- <<python 核心编程>>第一章 正则表达式
- hdu6055 Regular polygon 2017多校联盟2 11题 -枚举
- 2017 Multi-University Training Contest
- 用C++实现双向链表
- poj 2104 K-th Number (主席树)
- 妙用Linux 的后台任务
- noip系列 2004提高组 合并果子
- BFC原理与清除浮动的关系
- 树状数组的基本运用
- 树状数组的基本+运用(HDU1166-敌兵布阵)