NYOJ 1099 Lan Xiang's Square (判断是否为正四边形)
来源:互联网 发布:张国荣最冷一天知乎 编辑:程序博客网 时间:2024/06/05 05:54
Lan Xiang's Square
时间限制:1000 ms | 内存限制:65535 KB
难度:0
- 描述
Excavator technology which is strong, fast to Shandong to find Lan Xiang.
Then the question comes.. :)
for this problem , i will give you four points. you just judge if they can form a square.
if they can, print "Yes", else print "No".
Easy ? just AC it.
- 输入
- T <= 105 cases.
for every case
four points, and every point is a grid point .-10^8 <= all interger <= 10^8。
grid point is both x and y are interger. - 输出
- Yes or No
- 样例输入
11 1-1 1-1 -11 -1
- 样例输出
Yes
- 提示
you think this is a easy problem ? you dare submit, i promise you get a WA. :)
水
大意:给出四个点,判断围成的图形是否为正四边形
思路:直接判断是否最短边存在4条,最长边存在两条就行了,可以自己手绘一下
ac代码:
#include<stdio.h>#include<math.h>#include<string.h>#include<iostream>#include<algorithm>#define MAXN 201000#define MAX(a,b) a>b?a:b#define fab(a) ((a)>0?(a):-(a))#define mem(x) memset(x,0,sizeof(x))#define INF 0xfffffffusing namespace std;struct s{double x,y;}a[5];double dis[MAXN];double fun(s aa,s bb){return sqrt((aa.x-bb.x)*(aa.x-bb.x)+(aa.y-bb.y)*(aa.y-bb.y));}int main(){int t,i,j;scanf("%d",&t);while(t--){for(i=1;i<=4;i++)scanf("%lf%lf",&a[i].x,&a[i].y);double M=-1.0,mi=INF*1.0;int k=0;for(i=1;i<=4;i++){for(j=i+1;j<=4;j++){dis[k]=fun(a[i],a[j]);M=max(dis[k],M);mi=min(dis[k],mi);k++;}}int b=0,c=0;for(i=0;i<k;i++){if(dis[i]==M)b++;else if(dis[i]==mi)c++;}if(b==2&&c==4)printf("Yes\n");elseprintf("No\n");}return 0;}
0 0
- NYOJ 1099 Lan Xiang's Square (判断是否为正四边形)
- Lan Xiang's Square nyoj 1099(已经四边形四点坐标 如何判断正方形)
- nyoj 1099 Lan Xiang's Square(判断正方形问题)
- NYOJ 1099 Lan Xiang's Square(给出四点判断是否能构成正方形)
- nyoj 1099 Lan Xiang's Square (水题)
- Lan Xiang's Square
- Lan Xiang's Square
- Lan Xiang's Square 1099 (简单几何 较坑 )
- 计算当前四边形是否为凸四边形
- HDU 5365 Run (判断正四边形)
- NYOJ-1015(判断是否为二分图)
- s:if 判断List是否为空
- hdu5365 暴力枚举所有点是否能够成正四边形
- C++判断点是否四边形内部
- poj2318toys判断点是否在四边形内
- 367. Valid Perfect Square--判断一个数是否为完全平方数
- Struts2 s:iterator中判断字符串是否为空
- <s:if><c:if>判断参数是否为空
- Java加密技术(一)——BASE64与单向加密算法MD5&SHA&MAC
- An Overview of Tomcat 6 Servlet Container : Part 1
- iptables的技术
- 函数的补充
- An Overview of Tomcat 6 Servlet Container: Part 2
- NYOJ 1099 Lan Xiang's Square (判断是否为正四边形)
- iOS中使用ZBar扫描二维码自定义扫描界面
- android gifj加载
- 使用《UrlHash/锚点》解决移动设备中的单页面应用的物理[返回键]带来的困扰
- NDK
- Hbase快速开始——shell操作
- 解决 IOS9.0 调用qq2.91SDK登录 只显示web页面而不能调用客户端登录的问题
- 记录学习中的点点滴滴
- IntelliJ新建一个web工程