nyoj-1099-Lan Xiang's Square(几何,水题)
/*
Name:nyoj-1099-Lan Xiang's Square
Copyright:
Author:
Date: 2018/4/26 9:19:19
Description:
给4个点,判断是否形成正方形
double类型的值比较大小,直接判断==0竟然A了,然而小于1e-6竟然WA
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
struct node {
double x, y;
}nodes[];
double length_edge(node a, node b) {
return (b.x - a.x)*(b.x - a.x) + (b.y - a.y)*(b.y - a.y);
}
int main()
{
// freopen("in.txt", "r", stdin);
int t;
cin>>t;
while (t--) {
for (int i=; i<; i++)
cin>>nodes[i].x>>nodes[i].y;
double edge[];
edge[] = length_edge(nodes[], nodes[]);
edge[] = length_edge(nodes[], nodes[]);
edge[] = length_edge(nodes[], nodes[]);
if (count(edge, edge+, ) >) {
cout<<"No"<<endl;
continue;
}
sort(edge, edge+);
// if (edge[0] - edge[2] + edge[1] < 1e-6 && (edge[0] - edge[1]) < 1e-6) { //WA
if (edge[] - edge[] + edge[] == && (edge[] - edge[]) == ) {
cout<<"Yes"<<endl;
} else {
cout<<"No"<<endl;
}
}
return ;
}
nyoj-1099-Lan Xiang's Square(几何,水题)的更多相关文章
- ACM: FZU 2110 Star - 数学几何 - 水题
FZU 2110 Star Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Pr ...
- UVA 11461 - Square Numbers(水题)
题目链接 #include <cstdio> #include <cstring> #include <string> #include <cmath> ...
- C 几何水题 求不同斜率的数目 枚举+set
Description Master LU 非常喜欢数学,现在有个问题:在二维空间上一共有n个点,LU每连接两个点,就会确定一条直线,对应有一个斜率.现在LU把平面内所有点中任意两点连线,得到的斜率放 ...
- POJ 2002 Squares 几何, 水题 难度: 0
题目 http://poj.org/problem?id=2002 题意 已知平面内有1000个点,所有点的坐标量级小于20000,求这些点能组成多少个不同的正方形. 思路 如图,将坐标按照升序排列后 ...
- zzulioj--1746--三角形面积(几何水题)
1746: 三角形面积 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 100 Solved: 31 SubmitStatusWeb Board De ...
- nyoj--1011--So Easy[II](数学几何水题)
So Easy[II] 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 这是一道基础的计算几何问题(其实这不提示大家也都看的出).问题描述如下: 给你一个N边形.且N边形 ...
- nyoj 1208——水题系列——————【dp】
水题系列 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 给你一个有向图,每条边都有一定的权值,现在让你从图中的任意一点出发,每次走的边的权值必须必上一次的权 ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- poj 1006:Biorhythms(水题,经典题,中国剩余定理)
Biorhythms Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 110991 Accepted: 34541 Des ...
随机推荐
- spring下配置shiro
1.web.xml中加入shiro的过滤器: <!-- Spring --> <!-- 配置Spring配置文件路径 --> <context-param> < ...
- C#数组存入引用类型
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Cont ...
- 基于 普通及Lambda方式实现策略模式
什么是策略模式 策略模式代表了解决一类算法的通用解决方案,你可以在运行时选择使用哪种方案.比如如何使用不同的条件(比如苹果的重量,或者颜色 )来筛选库存中的苹果.你可以将这一模式应用到更广泛的领域 , ...
- 调用settings.py的配置信息作为全局使用
项目中一些比较零散的信息可以保存在数据库,也可以保存在settings.py里面 并且这些变量也可以像引用数据里面的数据使用, 可以把信息保存在settings.py里面,也可以保存在数据 ...
- MapInfo 文件格式说明
MapInfo 文件格式说明(id.map.tab.dat) (1). 属性数据的表结构文件.TAB 属性数据表结构文件定义了地图属性数据的表结构,包括字段数.字段名称.字段类型和字段宽度.索引字段及 ...
- Java基础教程:泛型基础
Java基础教程:泛型基础 引入泛型 传统编写的限制: 在Java中一般的类和方法,只能使用具体的类型,要么是基本数据类型,要么是自定义类型.如果要编写可以应用于多种类型的代码,这种刻板的限制就会束缚 ...
- C51数据类型
- R基本画图
参考内容:闻博,R语言的绘图功能及应用案例 https://wenku.baidu.com/view/80f22fa50029bd64783e2c22.html R画图是以函数操作为基本的画图模式. ...
- linux中获取堆栈空间大小的方法
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include < ...
- mysql删除重复记录
Solution 1: Add Unique Index on your table: ALTER IGNORE TABLE `TableA` ADD UNIQUE INDEX (`member_id ...