题意:给n个整点,问用其中若干个做顶点能够成多少个正三角形或正四边形或正五边形或正六边形。

解法:出题人说

地球人都知道整点是不能构成正五边形和正三边形和正六边形的,所以只需暴力枚举四个点判断是否是正四边形即可。假如你不是地球人,那么即使暴力枚举正三边形和稍微不那么暴力地找正五边形和正六边形也是可以通过的(反正找不到)。

然而我的数学是体育老师教的……判正方形也写不明白……【哭晕在厕所

代码:

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<time.h>
#include<stdlib.h>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#define LL long long using namespace std; struct node
{
int x, y;
node(int x, int y) : x(x), y(y) {}
node() {}
} point[25];
bool judge2(node a, node b, node c)
{
if(((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) == (c.x - b.x) * (c.x - b.x) + (c.y - b.y) * (c.y - b.y)) &&
((a.x - b.x) * (c.x - b.x) + (a.y - b.y) * (c.y - b.y) == 0))
return true;
else return false;
}
int judge1(node a, node b, node c)
{
if(judge2(a, b, c))
return 1;
if(judge2(b, a, c))
return 2;
if(judge2(a, c, b))
return 3;
return 0;
}
int main()
{
int n;
while(~scanf("%d", &n))
{
int ans = 0;
for(int i = 0; i < n; i++)
{
int a, b;
scanf("%d%d", &a, &b);
point[i] = node(a, b);
}
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++)
{
int tmp = judge1(point[i], point[j], point[k]);
if(tmp)
{
if(tmp == 1)
{
if(judge2(point[i], point[l], point[k])) ans++;
}
else if(tmp == 2)
{
if(judge2(point[j], point[l], point[k])) ans++;
}
else
{
if(judge2(point[i], point[l], point[j])) ans++;
}
}
}
printf("%d\n", ans);
}
return 0;
}

  

HDU 5365 Run的更多相关文章

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

    本来准备睡觉.结果还是忍不住想把它A了.由于已经看了题解了, 题意:就是给你一些坐标.都是整数,求一些正多边形的数目,官方题讲解是地球人都知道整数坐标构不成正三角形.正五边形和正六边形的... 然而我 ...

  2. HDU 1109 Run Away

    题目大意:给一个矩阵的长宽,再给n个点,求矩阵区域内某个点到各个点的最小距离的最大值,输出所求点的坐标 这道题我还是写了随机化乱搞,不过由于比较懒于是就没有写模拟退火,不过也是可以AC的 我们先初始随 ...

  3. ACM计算几何题目推荐

    //第一期 计算几何题的特点与做题要领: 1.大部分不会很难,少部分题目思路很巧妙 2.做计算几何题目,模板很重要,模板必须高度可靠. 3.要注意代码的组织,因为计算几何的题目很容易上两百行代码,里面 ...

  4. BestCoder Round #50 (div.1) 1002 Run (HDU OJ 5365) 暴力枚举+正多边形判定

    题目:Click here 题意:给你n个点,有多少个正多边形(3,4,5,6). 分析:整点是不能构成正五边形和正三边形和正六边形的,所以只需暴力枚举四个点判断是否是正四边形即可. #include ...

  5. 洛谷P1464 Function  HDU P1579 Function Run Fun

    洛谷P1464 Function HDU P1579 Function Run Fun 题目描述 对于一个递归函数w(a,b,c) 如果a≤0 or b≤0 or c≤0就返回值11. 如果a> ...

  6. hdu 1331 Function Run Fun

    Problem Description We all love recursion! Don't we? Consider a three-parameter recursive function w ...

  7. HDU 1331 Function Run Fun(记忆化搜索)

    Problem Description We all love recursion! Don't we? Consider a three-parameter recursive function w ...

  8. HDU——PKU题目分类

    HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...

  9. ACM: HDU 1869 六度分离-Dijkstra算法

    HDU 1869六度分离 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Descri ...

随机推荐

  1. G家二面

    题目都很基本,都属于听说过但是不会做的…都是操作系统,compiler的概念题… 概念题郁闷就郁闷在不会就是不会,就算能扯两句也会被问倒… 算法就一个,pow(x, y),5分钟不到…… 不是听说G家 ...

  2. JAVA WEB中如何让数据库连接对开发人员完全透明?

    书上的技术,确实开了眼界. 列相关测试代码如下,慢慢体会开发的模式. PropsUtil package org.smart4j.chapter2.util; import java.io.FileN ...

  3. hdu 4335 What is N?

    此题用到的公式:a^b%c=a^(b%phi(c)+phi(c))%c (b>=phi(c)). 1.当n!<phi(p)时,直接暴力掉: 2.当n!>=phi(p) &&a ...

  4. [SQL Server系] -- 约束

    什么是约束? 约束(Constraint)是SQL Server中提供的 自动保存数据库完整性 的一种方法,定义了可输入表或表的列中的数据限制条件. SQL Server中共有5中约束 PRIMARY ...

  5. Project Euler 91:Right triangles with integer coordinates 格点直角三角形

    Right triangles with integer coordinates The points P (x1, y1) and Q (x2, y2) are plotted at integer ...

  6. lintcode 中等题:Single number III 落单的数III

    题目 落单的数 III 给出2*n + 2个的数字,除其中两个数字之外其他每个数字均出现两次,找到这两个数字. 样例 给出 [1,2,2,3,4,4,5,3],返回 1和5 挑战 O(n)时间复杂度, ...

  7. Matlab中编译C++文件

    今天在跑<Robust Object Tracking via Sparsity-based Collaborative Model>这篇文章的代码时候,发现出现如下错误: 发现错误时由于 ...

  8. java登陆验证码与JS无刷新验证

    最近公司的项目的登陆模块由我负责,所以就做了个登陆小功能进行练手,其包括了用jQuery对用户名和密码进行不为null验证,和出于安全性考虑加了一个验证码的校验 别的不说先上代码 controller ...

  9. Android:Context的作用

    Context字面意思上下文,Activity中我们直接用this代替,而到了一个button的onClick(View view)等方法时,我们用this时就会报错,改用ActivityName.t ...

  10. ArcGIS 10.1 for Desktop新特性之地理标记照片

    转自:http://blog.csdn.net/esrichinacd/article/details/7730825 地理标记照片是指带有地理位置信息的照片,通常通过内置GPS的数码相机或智能手机拍 ...