HDU 6055 Regular polygon(几何)
来源:互联网 发布:马尔科夫转移矩阵 编辑:程序博客网 时间:2024/05/18 02:39
Regular polygon
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 643 Accepted Submission(s): 232
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个点,问你可以确定几个不同的正多边形。
POINT:
一顿瞎猜成功知道了只有正方形的情况。之后反正只有500个点,就遍历2个点,可以确定2个正方形,看看另外2对顶点存不存在就行了,别忘记/8去重。
因为mp数组来记录地图上有没有点,并且把负点都加了200来变正,那么点在判断的时候其实会超出地图一倍。
比如(0,300)和(300,300) 你得判断(300,600)-(0,600)和(0,0)-(300,0)有没有点,所以数组要开大,干脆开一千。还有就是点为负的情况去掉,也会数组越界。上面的点都处理变正了,不需要考虑负点。
#include <iostream>#include <string.h>#include <stdio.h>#include <algorithm>using namespace std;#define LL long longint mp[1000][1000];int x[555],y[555];int main(){ int n; while(~scanf("%d",&n)) { memset(mp,0,sizeof mp); for(int i=1;i<=n;i++) { scanf("%d %d",&x[i],&y[i]); x[i]+=200,y[i]+=200; mp[x[i]][y[i]]=1; } int ans=0; for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { if(i==j) continue; int a=x[i]-x[j]; int b=y[i]-y[j]; if(x[i]-b>=0&&y[i]+a>=0&&x[j]-b>=0&&y[j]+a>=0&&mp[x[i]-b][y[i]+a]&&mp[x[j]-b][y[j]+a]) { ans++; } if(x[i]+b>=0&&y[i]-a>=0&&x[j]+b>=0&&y[j]-a>=0&&mp[x[i]+b][y[i]-a]&&mp[x[j]+b][y[j]-a]) ans++; } } printf("%d\n",ans/8); }}
阅读全文
0 0
- HDU 6055 Regular polygon(几何)
- HDU 6055 Regular polygon【几何】
- 【几何】hdu 6055 Regular polygon
- HDU 6055 Regular polygon(几何数学)(多校2)
- HDU 6055 Regular polygon (计算几何 + 国家队论文结论)
- Regular polygon(HDU 6055)
- (2017多校2)1011/hdu-6055 Regular polygon(计算几何)
- [HDU]-6055 Regular polygon
- hdu-6055-Regular polygon
- Regular polygon HDU 6055
- hdu--6055--Regular polygon
- HDU 6055 Regular polygon
- hdu 6055 Regular polygon
- hdu 6055 Regular polygon
- HDU 6055 Regular polygon
- hdu 6055 Regular polygon
- hdu 6055 Regular polygon
- HDU 6055 Regular polygon
- LintCode Guess Number Game II
- 从零单排-python-01
- 第一次做的爬虫
- python 中threading的运用
- math库和random库
- HDU 6055 Regular polygon(几何)
- 可以在 JavaScript 中创建三种消息框:警告框、确认框、提示框。
- 1009. 说反话 (20)
- LeetCode 455 Assign Cookies
- android 与Java后台交互
- 无线传感网技术学习
- Mysql 基础操作
- J
- POJ1284 Primitive Roots【原根】