nyoj-1099-Lan Xiang's Square(几何,水题)

题目链接

 1 /*
 2     Name:nyoj-1099-Lan Xiang‘s Square
 3     Copyright:
 4     Author:
 5     Date: 2018/4/26 9:19:19
 6     Description:
 7     给4个点,判断是否形成正方形
 8     double类型的值比较大小,直接判断==0竟然A了,然而小于1e-6竟然WA
 9 */
10 #include <iostream>
11 #include <cstdio>
12 #include <algorithm>
13 using namespace std;
14 struct node {
15     double x, y;
16 }nodes[5];
17 double length_edge(node a, node b) {
18     return (b.x - a.x)*(b.x - a.x) + (b.y - a.y)*(b.y - a.y);
19 }
20 int main()
21 {
22 //    freopen("in.txt", "r", stdin);
23     int t;
24     cin>>t;
25     while (t--) {
26         for (int i=0; i<4; i++)
27             cin>>nodes[i].x>>nodes[i].y;
28         double edge[4];
29         edge[0] = length_edge(nodes[0], nodes[1]);
30         edge[1] = length_edge(nodes[0], nodes[2]);
31         edge[2] = length_edge(nodes[0], nodes[3]);
32         if (count(edge, edge+3, 0) >0) {
33             cout<<"No"<<endl;
34             continue;
35         }
36         sort(edge, edge+3);
37 //        if (edge[0] - edge[2] + edge[1] < 1e-6 && (edge[0] - edge[1]) < 1e-6) { //WA
38         if (edge[0] - edge[2] + edge[1] ==0  && (edge[0] - edge[1])  == 0) {
39             cout<<"Yes"<<endl;
40         } else {
41             cout<<"No"<<endl;
42         }
43     }
44     return 0;
45 }

nyoj-1099-Lan Xiang's Square(几何,水题)

原文地址:https://www.cnblogs.com/evidd/p/8949784.html

时间: 2024-10-03 10:01:47

nyoj-1099-Lan Xiang's Square(几何,水题)的相关文章

nyoj 1099 Lan Xiang&#39;s Square (水题)

题目1099 题目信息 运行结果 本题排行 讨论区 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

C 几何水题 求不同斜率的数目 枚举+set

Description Master LU 非常喜欢数学,现在有个问题:在二维空间上一共有n个点,LU每连接两个点,就会确定一条直线,对应有一个斜率.现在LU把平面内所有点中任意两点连线,得到的斜率放入一个集合中(若斜率不存在则不计入集合),他想知道这个集合中有多少个元素. Input 第一行是一个整数T,代表T组测试数据每组数据第一行是一个整数n,代表点的数量.2<n<1000接下来n行,每行两个整数,0<=x<10000,0<=y<10000,代表点的坐标 Outp

ACM: FZU 2110 Star - 数学几何 - 水题

FZU 2110  Star Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Practice Description Overpower often go to the playground with classmates. They play and chat on the playground. One day, there are a lot of stars in the sky.

nyoj 1208——水题系列——————【dp】

水题系列 时间限制:1000 ms  |  内存限制:65535 KB 难度:2 描述     给你一个有向图,每条边都有一定的权值,现在让你从图中的任意一点出发,每次走的边的权值必须必上一次的权值大的情况下,问你最多能走几条边? 输入 首先一个n和m,分别表示点的数目和边的数目接下来m行,每行三个值x,y,val,表示x到y有路,其权值为val.(1<n,m,val<10^5,0<x,y<=n) 输出 输出最多有的边的数目 样例输入 3 3 1 2 1 2 3 1 3 1 1 6

POJ百道水题列表

以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight Moves1101 Gamblers1204 Additive equations 1221 Risk1230 Legendary Pokemon1249 Pushing Boxes 1364 Machine Schedule1368 BOAT1406 Jungle Roads1411 Annive

HDU 4007 Dave (基本算法-水题)

Dave Problem Description Recently, Dave is boring, so he often walks around. He finds that some places are too crowded, for example, the ground. He couldn't help to think of the disasters happening recently. Crowded place is not safe. He knows there

poj 1005:I Think I Need a Houseboat(水题,模拟)

I Think I Need a Houseboat Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 85149   Accepted: 36857 Description Fred Mapper is considering purchasing some land in Louisiana to build his house on. In the process of investigating the land,

hdu-5641 King&#39;s Phone (水题)

题目链接: King's Phone Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 418    Accepted Submission(s): 123 Problem Description In a military parade, the King sees lots of new things, including an An

5.1个人赛解题报告(区间dp,按位与或,图论等水题)

这次5.1打了一场个人赛,已经连赛了三周了,有点疲惫感觉,可能自己太水了,每次都有点小紧张. 这次只解出来三道题,然而有一道按位与按位或的水题不知道思路实在是做题太少,还有就是第一题区间DP,也消耗了不少的时间,但是没有成功的写出来,还是不够熟练啊. 下面写报告 A. System Administrator time limit per test 2 seconds memory limit per test 256 megabytes input standard input output