hdu5365 Run
来源:互联网 发布:小熊相机软件 编辑:程序博客网 时间:2024/05/19 13:26
Link: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): 529 Accepted Submission(s): 231
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.
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.
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
40 00 11 01 1
Sample Output
1
Source
BestCoder Round #50 (div.2)
编程思想:由于输入数据x、y坐标是整数,对应的点连起来不可能是正三角形、正五边形和正六边形,只可能是正四边形。根据正四边形的判定定理:四条边相等且有一个角是直角的四边形是正四边形。通过枚举每四个点所构成的六条边,若这四个点能构成正四边形,则其所构成的六条边中有四条是正四边形的边,另外两条是正四边形的对角线,且对角线比边长,故通过从小到大排序即可判断前4条边为正四边形的边,后两条为对角线。根据正四边形的边相等和正四边形的对角线与正四边形的边构成直角三角形的勾股关系,即可判定是否为正四边形。
AC code:
#include<stdio.h>#include<string.h>#include<stdlib.h>#include<queue>#include<math.h>#include<vector>#include<map>#include<set>#include<cmath>#include<string>#include<algorithm>#include<iostream>#define LL long long #define exp 1e-10#define MAXN 1000010using namespace std;const int INF=0x3f3f3f3f;const int N = 100005;const int mod = 1000000007;int n,i,j,k,l,ans;int x[33],y[33]; int e[33];int main(){ while(scanf("%d",&n)!=EOF) { for(i=1;i<=n;i++) { scanf("%d%d",&x[i],&y[i]);}ans=0;for(i=1;i<=n;i++){for(j=i+1;j<=n;j++){for(k=j+1;k<=n;k++){for(l=k+1;l<=n;l++){e[1]=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);e[2]=(x[i]-x[k])*(x[i]-x[k])+(y[i]-y[k])*(y[i]-y[k]);e[3]=(x[i]-x[l])*(x[i]-x[l])+(y[i]-y[l])*(y[i]-y[l]);e[4]=(x[j]-x[k])*(x[j]-x[k])+(y[j]-y[k])*(y[j]-y[k]);e[5]=(x[j]-x[l])*(x[j]-x[l])+(y[j]-y[l])*(y[j]-y[l]);e[6]=(x[k]-x[l])*(x[k]-x[l])+(y[k]-y[l])*(y[k]-y[l]);sort(e+1,e+7);if(e[1]==e[2]&&e[2]==e[3]&&e[3]==e[4]&&e[3]+e[4]==e[5]){ans++;}}}}}printf("%d\n",ans);}}
0 0
- hdu5365 Run
- hdu5365
- hdu5365
- BestCoder Round #50 Run 即 hdu5365(暴力枚举)
- hdu5365(几何)
- hdu5365 简单几何问题
- hdu5365 判断四个点是否构成正方形
- run
- hdu5365 暴力枚举所有点是否能够成正四边形
- 1021 Run Run Run!
- POJ2002 &&HDU5365 判断给定的点中有多少个不同的正方形
- Run Papa Run
- Run, Rpi-car, run!
- Service.Run()
- start->run
- run命令
- Run command
- memcached.run
- const和mutable
- 对商业方,架构师要避免愤世嫉俗
- Zend Guard6.0使用教程——PHP代码加密
- 大整数乘法问题
- poj 1470 lca-targan离线算法
- hdu5365 Run
- 如何将JAVA工程转为MAVEN工程
- 使用butterknife中遇到的几个问题及解决方法
- hiho一下 第五十八周 Beautiful String dp
- javascript以及衍生框架自学笔记
- 教你自定义竖直跑马灯效果(广告专用)
- Window与Linux跨平台JAVA编程的注意事项
- Mysql之存储过程回顾
- jquery的DOM定位与操作