hdu 5365 Run 几何 判定四边形


欢迎参加——每周六晚的BestCoder(有米!)

Run

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 563    Accepted Submission(s): 253

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)

Recommend

题目说的有点不清,其实就是要求正方形的个数就可以了。由于整点无法形成正三角形 正五边形 正六边形。判定正方形,只需要,四边相等,对角线相等,也对角线是边的2倍就可以了。

#define N 205
#define M 100005
#define maxn 205
#define MOD 1000000000000000007
int n,xx[N],yy[N];
bool isRec(int a,int b,int c,int d){
    int ll[7],len = 0,e[4];
    e[0] = a;e[1] = b;e[2] = c;e[3] = d;
    for(int i = 0;i<4;i++){
        for(int j = i + 1;j<4;j++){
            ll[len++] = (xx[e[i]] - xx[e[j]]) * (xx[e[i]] - xx[e[j]]) +
                        (yy[e[i]] - yy[e[j]]) * (yy[e[i]] - yy[e[j]]);
        }
    }
    sort(ll,ll+len);
    if(ll[0] == ll[1] && ll[1] == ll[2] && ll[2] == ll[3] && ll[4] == 2 * ll[3]&& ll[4] == ll[5])
        return true;
    return false;
}
int main()
{
     while(S(n)!=EOF)
    {
        FI(n){
            S2(xx[i],yy[i]);
        }
        int ans = 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 s = k+1;s<n;s++){
                            if(isRec(i,j,k,s)){
                                ans++;
                            }
                    }
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-10-10 16:04:32

hdu 5365 Run 几何 判定四边形的相关文章

BestCoder Round #50 (div.2) HDU 5365 Run(简单几何)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5365 题面:(严重吐槽,看着真不舒服,还是改一下吧) Run Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 549    Accepted Submission(s): 245 Problem Description AFA is a g

hdu 5365 Run(BC 50 B题)(求四边形的个数)

本来准备睡觉,结果还是忍不住想把它A了,因为已经看了题解了, 题意:就是给你一些坐标,都是整数,求一些正多边形的数目,官方题解说是地球人都知道整数坐标构不成正三角形,正五边形和正六边形的...然而我并不知道...以后才知道... 所以呢这道题直接暴力就可以了,求正四边形的个数,这里判断是否是正四边形用的是四条边相等,而且两条对角线相等,并且边比对角线小,我也不知道是否这样一定是正四边形(...) 放代码: #include<iostream> #include<cstdio> #i

HDU 5365 Run(大水题)

大致题意: 8*8的整点格子,输入16个整点,求多少种点的集合可以组成正3,正4,5,6边形 思路:sb题啊...整点格子组成不了n !=4的所有正多边形,只要判是否能组成正方形就可以了 这里有个优美的无穷递降的证明:http://www.zhihu.com/question/25304120 而我是枚举所有点的集合判断是否能组成正多边形的蠢方法= =,先用凸包对点排个序,然后判各点距离相等和用余弦定理判个顶角相等..... //#pragma comment(linker, "/STACK:1

HDU 5365 Run

因为给出的点都是整数,都在网格上的,所以正三角形,正五边形,正六边形都是不存在的. 暴力枚举四个点,判断一下是不是正方形即可. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; int n; int x[30],y[30]; class Coordinate { public: double xCoordinate; doub

HDU 5365 Run(暴力)

题意:给一个n和n个整数坐标问这些点能组成几个不同正三角形,正方形,正五边形,正六边形. 分析:由于坐标都是整数,使用只可能有正方形,其他都不可能,那么只要对于每四个不同的点,判断2组对边相等,两条对角线也相等,临边也相等即可. 代码: #include <iostream> #include <cstdio> #include <cstring> #include <queue> #include <algorithm> #pragma com

HDU 4709 Herding 几何题解

求所有点组成的三角形最小的面积,0除外. 本题就枚举所有可以组成的三角形,然后保存最小的就是答案了,因为数据量很少. 复习一下如何求三角形面积.最简便的方法就是向量叉乘的知识了. 而且是二维向量叉乘P1(ax, ay), P2(bx, by),公式为:|P1 X P2| = abs(ax*by - ay*bx) 三角形面积就是|P1 X P2| / 2; 本题也是float过不了,换成double就可以过了. const int MAX_N = 101; struct VertexPoint {

HDU 2829 Lawrence(动态规划-四边形不等式)

Lawrence Problem Description T. E. Lawrence was a controversial figure during World War I. He was a British officer who served in the Arabian theater and led a group of Arab nationals in guerilla strikes against the Ottoman Empire. His primary target

HDU 3656 二分+dlx判定

Fire station Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1308    Accepted Submission(s): 434 Problem Description A city's map can be seen as a two dimensional plane. There are N houses in

hdu 5365 (bc #50 1002 )Run

Run Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 594    Accepted Submission(s): 265 Problem Description AFA is a girl who like runing.Today,he download an app about runing .The app can record