题意:给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. hdu 1180 诡异的楼梯(广搜,简单)

    题目 挺简单的一道广搜题,只要用判断时间是偶数还是奇数就可以判断楼梯的方位,但是我这傻逼居然写了那么久啊那么久,我果然秀逗了,,,, #define _CRT_SECURE_NO_WARNINGS # ...

  2. 【leetcode】Median of Two Sorted Arrays(hard)★!!

    There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted ...

  3. mybatis 插入日期类型精确到秒的有关问题

    mybatis 插入日期类型精确到秒的问题 Mybatis 插入 数据库是为了防止插入空时报错, Mybatis 提供了一套机制,只要给定插入的字段的类型,如果为空,则它会自动处理为相应类型的默认值: ...

  4. hdu 4579 Random Walk 概率DP

    思路:由于m非常小,只有5.所以用dp[i]表示从位置i出发到达n的期望步数. 那么dp[n] = 0 dp[i] = sigma(dp[i + j] * p (i , i + j)) + 1 .   ...

  5. 360 chrome 国际版能够隐藏用户保存的密码

    用360 chrome 国际版一段时间了,今天发现它一个优点:取消了浏览器保存的密码明文显示! 原生的chrome和枫树都会明文显示密码,360 chrome国际版则只显示保存了密码的域名和账户名.光 ...

  6. Java并发:Callable、Future和FutureTask

    Java并发编程:Callable.Future和FutureTask 在前面的文章中我们讲述了创建线程的2种方式,一种是直接继承Thread,另外一种就是实现Runnable接口. 这2种方式都有一 ...

  7. 用 React 编写2048游戏

    1.代码 <!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="U ...

  8. HDU5090——Game with Pearls(匈牙利算法|贪心)(2014上海邀请赛重现)

    Game with Pearls Problem DescriptionTom and Jerry are playing a game with tubes and pearls. The rule ...

  9. HDU-4661 Message Passing 树形DP,排列组合

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4661 题意:有n个人呈树状结构,每个人知道一个独特的消息.每次可以让一个人将他所知的所有消息告诉和他相 ...

  10. 车牌识别LPR(三)-- LPR系统整体结构

    第三篇:系统的整体架构 LPR系统大体上可由图像采集系统,图像处理系统,数据库管理系统三个子系统组成.它综合了通讯.信息.控制.传感.计算机等各种先进技术,构成一个智能电子系统. 图像采集系统:图像采 ...