http://acm.hdu.edu.cn/showproblem.php?pid=5365
Problem Description
AFA is a girl who like runing.Today,he download an app about runing .The app can record the trace of her runing.AFA will start runing in the park.There are many chairs in the park,and AFA will start his runing in a chair and end in this chair.Between two chairs,she
running in a line.she want the the trace can be a regular triangle or a square or a regular pentagon or a regular hexagon.
Please tell her how many ways can her find.
Two ways are same if the set of chair that they contains are same.
Input
There are multiply case.
In each case,there is a integer n(1 < = n < = 20)in a line.
In next n lines,there are two integers xi,yi(0 < = xi,yi < 9) in each line.
Output
Output the number of ways.
Sample Input
4 0 0 0 1 1 0 1 1
Sample Output
1
/** hdu5365 简单几何问题 题目大意:小花是一个热爱健身的姑娘,这天她下载了一个跑步软件,这个软件可以记录下小花跑步的轨迹。小花决定去公园跑步。 公园里有许许多多的座椅,小花希望在一些座椅休息一下,并且她在两条座椅之间只跑直线。小花是一个完美主义者, 她希望自己最后的轨迹是一个正三边形或者正四边形或者正五边形或者正六边形。小花会从某条座椅开始打开跑步软件, 并在回到这个座椅后关闭。请问小花有多少种跑法。注:若两种跑法经过的座椅集合相同则认为是一种跑法。且经过一 条座椅时没有必要一定停下来 解题思路:地球人都知道整点是不能构成正五边形和正三边形和正六边形的,所以只需暴力枚举四个点判断是否是正四边形即可。 假如你不是地球人,那么即使暴力枚举正三边形和稍微不那么暴力地找正五边形和正六边形也是可以通过的(反正找不到)。 */ #include <stdio.h> #include <string.h> #include <algorithm> #include <iostream> #include <vector> using namespace std; struct note { int x,y; }a[105]; int n; int len(int x,int y,int u,int v) { return (x-u)*(x-u)+(y-v)*(y-v); } int judge(int i,int j,int k,int l)///片面内给定四个点的坐标判断是否构成正方形(求出各边长,排序,判断边的关系) { vector <int> vec; vec.push_back(len(a[i].x,a[i].y,a[j].x,a[j].y)); vec.push_back(len(a[i].x,a[i].y,a[k].x,a[k].y)); vec.push_back(len(a[i].x,a[i].y,a[l].x,a[l].y)); vec.push_back(len(a[j].x,a[j].y,a[k].x,a[k].y)); vec.push_back(len(a[k].x,a[k].y,a[l].x,a[l].y)); vec.push_back(len(a[l].x,a[l].y,a[j].x,a[j].y)); sort(vec.begin(),vec.end()); if(vec[0]==vec[1]&&vec[1]==vec[2]&&vec[2]==vec[3]&&vec[1]*2==vec[4]&&vec[4]==vec[5]) return true; return false; } int main() { while(~scanf("%d",&n)) { for(int i=0;i<n;i++) { scanf("%d%d",&a[i].x,&a[i].y); } int sum=0; for(int i=0;i<n;i++) { for(int j=i+1;j<n;j++) { for(int k=j+1;k<n;k++) { for(int l=k+1;l<n;l++) { if(judge(i,j,k,l))sum++; } } } } printf("%d\n",sum); } return 0; }
版权声明:本文为博主原创文章,未经博主允许不得转载。