HDU-6055-Regular polygon
来源:互联网 发布:妲己 女娲 知乎 编辑:程序博客网 时间:2024/05/01 17:53
Regular polygon
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2546 Accepted Submission(s): 1018
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
解题代码
#include <iostream>#include <stdio.h>#include <string.h>using namespace std;struct node{ int x,y;}ch[505];int vis[205][205];int main(){ int N; while(scanf("%d",&N)!=EOF) { memset(vis,0,sizeof(vis)); for(int i=1;i<=N;i++) { scanf("%d%d",&ch[i].x,&ch[i].y); ch[i].x+=100; ch[i].y+=100; vis[ch[i].x][ch[i].y]=1; } int count1=0; for(int i=1;i<=N;i++) for(int j=i+1;j<=N;j++) { int x1=ch[i].x; int y1=ch[i].y; int x2=ch[j].x; int y2=ch[j].y; int dx=ch[i].x-ch[j].x; int dy=ch[i].y-ch[j].y; if(x1+dy>=0&&x1+dy<=200&&y1-dx>=0&&y1-dx<=200&&x2+dy>=0&&x2+dy<=200&&y2-dx>=0&&y2-dx<=200) { if(vis[x1+dy][y1-dx]==1&&vis[x2+dy][y2-dx]==1) count1++; } if(x1-dy>=0&&x1-dy<=200&&y1+dx>=0&&y1+dx<=200&&x2-dy>=0&&x2-dy<=200&&y2+dx>=0&&y2+dx<=200) { if(vis[x1-dy][y1+dx]==1&&vis[x2-dy][y2+dx]==1) count1++; } } printf("%d\n",count1/4); } return 0;}
阅读全文
0 0
- [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
- HDU 6055 Regular polygon
- HDU 6055 Regular polygon
- HDU-6055 Regular polygon
- HDU-6055-Regular polygon
- 【HDU 6055 Regular polygon】+ map
- Regular polygon(HDU 6055)
- HDU 6055 Regular polygon【几何】
- JS类型转换
- 2017 多校 3(6056-6066)进度(5/11)
- CI中的load理解
- 「网络流 24 题」分配问题
- Android护眼模式功能小记
- HDU-6055-Regular polygon
- goolge浏览器插件
- (HDU
- POST解析(Imagerloader、异步、图片、文字、listv显示)
- View事件传递
- spring security
- 创建maven出现的问题
- win10环境下vc++6.0安装插件报unable to register........
- 数据采样后的CTR矫正