HDU-5365-Run

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

Source
BestCoder Round #50 (div.2)

—————————————-并不华丽的分界线—————————-
题目大意:小花是一个热爱健身的姑娘,这天她下载了一个跑步软件,这个软件可以记录下小花跑步的轨迹。小花决定去公园跑步。公园里有许许多多的座椅,小花希望在一些座椅休息一下,并且她在两条座椅之间只跑直线。小花是一个完美主义者,她希望自己最后的轨迹是一个正三边形或者正四边形或者正五边形或者正六边形。小花会从某条座椅开始打开跑步软件,并在回到这个座椅后关闭。请问小花有多少种跑法。注:若两种跑法经过的座椅集合相同则认为是一种跑法。且经过一条座椅时没有必要一定停下来

对于这道题,题解上说的已经非常发人深醒了,就不再多说了,直接暴力的搞就好。

/*
明显可以得到,整点只能构成正四边形。
以正三角形为例,固定一个整点为顶点,以该点为圆心,三角形的边长为半径画圆。
因为正三角形的每个内角都为60°,则取圆与整点之间的距离为半径,再向左向右取60°圆弧,发现无论任何取,都不可能找到第三点使得该点为整点。
同理可得五边形,六边形无法构成。
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;

const int maxn = 21;
struct node
{
    int x,y;
}point[maxn];

int Dis(node a, node b){
    return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
bool Judge(int *len){
    sort(len,len + 6);
    if( *len != *(len+1) || *len != *(len+2) || *len != *(len+3) ) return false;
    if( *(len+4) != *(len+5) ) return false;

    return true;
}
int main()
{
    int n;
    while(~scanf("%d",&n)){
        for(int i = 0; i < n; i++){
            scanf("%d%d", &point[i].x, &point[i].y);
        }
        int cont = 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 h = k + 1; h < n; h++){
                        int dis[6] = {0};
                        dis[0] = Dis(point[i], point[j]);
                        dis[1] = Dis(point[j], point[k]);
                        dis[2] = Dis(point[k], point[h]);
                        dis[3] = Dis(point[h], point[i]);
                        dis[4] = Dis(point[i], point[k]);
                        dis[5] = Dis(point[j], point[h]);

                        if(Judge(dis)){
                            cont ++;
                        }
                    }
                }
            }
        }

        printf("%d\n",cont);
    }
    return 0;
}
posted @ 2015-08-22 18:20  _Wilbert  阅读(144)  评论(0编辑  收藏  举报