2017 HDU 多校联合赛 Regular polygon
来源:互联网 发布:关于网络暴力的调查 编辑:程序博客网 时间:2024/06/05 15:56
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
题意:
在一个 xOy 的坐标轴上给你 n 个点,求你用这些点能连成多少个正多边形 ( 其实就是找能构成多少个正方形 ) 。
思路:
从500个点中枚举两个点,然后寻找另外两个点是否存在。
#include<cstdio>#include<cstring>#include<cmath>using namespace std;int Xa,Xb,Ya,Yb,n,xx,yy;int x[500+5],y[500+5],vis[200+5][200+5];int main(){ while(scanf("%d",&n)!=EOF) { memset(vis,0,sizeof(vis)); memset(x,0,sizeof(x)); memset(y,0,sizeof(y)); for(int i=0; i<n; i++) { scanf("%d %d",&x[i],&y[i]); x[i]+=100; y[i]+=100; vis[x[i]][y[i]]=1; } int ans=0; for(int i=0; i<n; i++) { for(int u=0; u<n; u++) { if(i==u) { continue; } else { xx=abs(x[i]-x[u]); yy=abs(y[i]-y[u]); if(x[i]<=x[u]&&y[i]<=y[u]) { if(x[i]+yy<=200&&y[i]-xx>=0&&x[u]+yy<=200&&y[u]-xx>=0) if(vis[x[i]+yy][y[i]-xx]==1&&vis[x[u]+yy][y[u]-xx]==1) { ans++; } if(x[i]-yy>=0&&y[i]+xx<=200&&x[u]-yy>=0&&y[u]+xx<=200) if(vis[x[i]-yy][y[i]+xx]==1&&vis[x[u]-yy][y[u]+xx]==1) { ans++; } } else if(x[i]<x[u]&&y[i]>y[u]) { if(x[i]+yy<=200&&y[i]+xx<=200&&x[u]+yy<=200&&y[u]+xx<=200) if(vis[x[i]+yy][y[i]+xx]==1&&vis[x[u]+yy][y[u]+xx]==1) { ans++; } if(x[i]-yy>=0&&y[i]-xx>=0&&x[u]-yy>=0&&y[u]-xx>=0) if(vis[x[i]-yy][y[i]-xx]==1&&vis[x[u]-yy][y[u]-xx]==1) { ans++; } } } } } printf("%d\n",ans/4); } return 0;}
阅读全文
0 1
- 2017 HDU 多校联合赛 Regular polygon
- 2017第二次多校联合Regular polygon
- HDU 2017 多校联合训练赛2 1011 6055 Regular polygon map&pair
- 2017多校联合第二场 1011题 hdu 6055 Regular polygon 计算几何
- HDU 2017多校联赛-Regular polygon
- HDU 2017 多校联赛2 1011 Regular polygon
- HDU-2017 多校训练赛2-1011-Regular polygon
- hdu 多校联赛 Regular polygon
- 17暑假多校联赛2.11 HDU 6055 Regular polygon
- 2017 多校训练第二场 HDU 6055 Regular polygon
- HDU6055 Regular polygon(计算几何,2017 HDU多校联赛 第2场)
- HDU 6053 TrickGCD+6055 Regular polygon【2017多校联赛2】
- 【2017多校第二场】HDU 6055 Regular polygon【几何,枚举】
- HDU 6055 (2017 多校训练赛2 1011)Regular polygon
- HDU (6055)Regular polygon (2017多校训练赛1011)
- hdu 4033 /成都网络赛 Regular Polygon
- hdu 4033 Regular Polygon
- [HDU]-6055 Regular polygon
- Linux的Centos安装nginx
- [Oracle分享]如何对一行结果为字符串的结果,进行大小判断。
- Android常用开源框架的源码解读套路--教你怎么读开源框架源码
- 闲暇时光-越是忙碌的时候,越想找一个地方,自在独处
- 2017/7/27 第四天
- 2017 HDU 多校联合赛 Regular polygon
- 对表空间 'USERS' 无权限
- Bear and Different Names
- spring-task的配置及使用
- Jmeter录制脚本相应数据产生乱码解决方案
- 面向对象地分析Linux内核设备驱动(3)——用面向对象思想分析vfb Framebuffer设备驱动
- Unity_NGUI介绍_038
- SpringBoot (六) :如何优雅的使用 mybatis
- 黄海高程和绝对高程之间的转换