BC之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) Recommend
hujie | We have carefully selected several similar problems for you: 5368 5367 5362 5361 5360 官方题解:
地球人都知道整点是不能构成正五边形和正三边形和正六边形的,所以只需暴力枚举四个点判断是否是正四边形即可。假如你不是地球人,那么即使暴力枚举正三边形和稍微不那么暴力地找正五边形和正六边形也是可以通过的(反正找不到)。 地球人都知道,我当时尽然猪脑子的没怎么注意这点,各种几何,各种优化,之后原来竟然酱紫...... 反证法:假设存在坐标平面上的三个整点,组成了正三角形
则将其平移,将其一个顶点与坐标原点重合,则另两个顶点仍然是整点
设一个非原点的顶点M坐标为(a,b) ,另一个顶点为N(c,d), a、b、c、d都是整数 则MO的斜率=,倾斜角=arctan(
)
则NO的倾斜角=arctan()+
NO的斜率=
![]()
因为a、b不全等于0,所以c和d至少有一个是无理数
这和c、d都是整数矛盾
所以坐标平面上的三个整点,一定不能组成正三角形 至于正五边形和正六边形,就交给你们自己去证明了。 判断正方形:
用一个数组用于保存四个点之间的距离,求出两两点之间的距离,若数组不存在所求的距离数值,则添加进数组,若数组超过三个数值,则返回FALSE,否则返回true(其实只要两个就行了,不用距离平方比为1/2,自己举例证明...) 也可以直接算出6个点之间的距离,排下序,前四个相同后两个相同就是正方形....#include<cstdio>
#include<cmath>
#include<stdlib.h>
#include<map>
#include<set>
#include<time.h>
#include<vector>
#include<queue>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define LL long long
#define rd(a) scanf("%d",&a)
#define rdLL(a) scanf("%I64d",&a)
#define rdd(a,b) scanf("%d%d",&a,&b)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define MOD 1000000007
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,1,sizeof(a))
typedef pair<int , int> P; int x[25],y[25]; double getdis(int x1,int y1,int x2,int y2){
return (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
} int judge(int temp[]){///判断是不是正方形
int dis[3], coun=0;
for(int xx=0;xx<4;xx++)
for(int yy=xx+1;yy<4;yy++){
int distmp = getdis(x[ temp[xx] ],y[ temp[xx] ],x[ temp[yy] ],y[ temp[yy] ]);
if(coun==0) dis[coun++]= distmp;
else if(coun==1)
{
if(distmp!=dis[0])
dis[coun++] = distmp;
}
else if(distmp != dis[0] && distmp != dis[1]) return false;
}
return true;
} int main()
{
int n;
while(~rd(n)){
for(int i=0;i<n;i++)
rdd(x[i],y[i]);
int coun = 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++){
int temp[4]={i,j,k,l};
if(judge(temp)) coun++;
}
printf("%d\n",coun);
}
return 0;
}
BC之Run的更多相关文章
- bc - An arbitrary precision calculator language
bc(1) General Commands Manual bc(1) NAME bc - An arbitrary precision calculator language SYNTAX bc [ ...
- Cognos报表打开参数
查看门户页面 http://localhost:9300/p2pd/servlet/dispatch? b_action=xts.run &m=portal/cc.xts &gohom ...
- sysbench_fileio.sh
当我--file-total-size=30G 并且指定3个文件的时候,结果是产生3个10G的文件,然而--max-time=20被忽视了,虽然指定了20s的限制,实际上是在prepare阶段,--m ...
- 从Go语言编码角度解释实现简易区块链
区块链技术 人们可以用许多不同的方式解释区块链技术,其中通过加密货币来看区块链一直是主流.大多数人接触区块链技术都是从比特币谈起,但比特币仅仅是众多加密货币的一种. 到底什么是区块链技术? 从金融学相 ...
- 从Go语言编码角度解释实现简易区块链——实现交易
在公链基础上实现区块链交易 区块链的目的,是能够安全可靠的存储交易,比如我们常见的比特币的交易,这里我们会以比特币为例实现区块链上的通用交易.上一节用简单的数据结构完成了区块链的公链,本节在此基础上对 ...
- hdu 5365 Run(BC 50 B题)(求四边形的个数)
本来准备睡觉.结果还是忍不住想把它A了.由于已经看了题解了, 题意:就是给你一些坐标.都是整数,求一些正多边形的数目,官方题讲解是地球人都知道整数坐标构不成正三角形.正五边形和正六边形的... 然而我 ...
- 【云计算】docker run详解
Docker学习总结之Run命令介绍 时间 2015-01-21 17:06:00 博客园精华区 ...
- hdu 1331 Function Run Fun
Problem Description We all love recursion! Don't we? Consider a three-parameter recursive function w ...
- HDU 1331 Function Run Fun(记忆化搜索)
Problem Description We all love recursion! Don't we? Consider a three-parameter recursive function w ...
随机推荐
- 彻底解决ASP.NET MVC 3 404错误码返回302的问题
转自:http://blog.csdn.net/mycloudke/article/details/9746333 404状态码:,意味着当在页面上显示用户点击不存在,提高用户体验度,搜索引擎会放弃这 ...
- ORA-27101:shared memory realm does not exist的问题
ORA-27101:shared memory realm does not exist的问题 登陆SQLPlus时出现: ORA-01034:ORACLE not avaiable ORA-2710 ...
- SQL Server 2008维护计划 出错 无法实现自动备份
,MaintenancePlan.Subplan_1,错误,0,HBZGQ\TESTSQLSERVER,MaintenancePlan.Subplan_1,(作业结果),,该作业失败. 用户 sa 调 ...
- Ruby Exception
begin #可能发生异常的地方 rescue #如何处理异常 end rescue,哈哈,太有爱的一个单词了... begin #可能发生异常的地方 rescue => exception # ...
- json 解析
纠结了两天的json数组反序列化,终于在同事的帮助下,找到方法了,特作笔记如下: using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Sy ...
- jQuery实现文字放大效果
实现效果:当鼠标移动到超链接的那一瞬间就出现提示. <!DOCTYPE html> <html> <head> <meta charset="UTF ...
- 解决RPM包相互依赖的有效方法
出自:http://blog.csdn.net/kai27ks/article/details/7473683 前言:常用RPM的朋友们都知道,RPM简单易用,但是它的依赖关系是最头疼的!有时候比方说 ...
- 在Huawei USG2100 上配置通过Huawei VPN客户端的接入
USG2100 设置 一.本地策略 中允许 Untrust 对 L2TP 的访问: 二.勾选 VPN-->L2TP 启用: 三.设置参数: 1.组类型选择LNS,本端隧道名称LNS,对端隧道名称 ...
- 204. Count Primes
Description: Count the number of prime numbers less than a non-negative number, n. ============= 找质数 ...
- mysql 常用操作(整理)
原文地址:http://blog.csdn.net/lxh090821/article/details/9410943 1 登录数据库 格式: mysql -h主机地址 -u用户名 -p用 ...