ZOJ2540 Form a Square
Form a Square
题意就是 判断 给你四个点,能否组成一个正方形
要点:
格式很重要, 很重要!!!
数据很小,直接暴力
四个点判断是否为正方形,只需将所有可能的边长度算出来,然后选其中最短的边作为正方形的边长,进行比较,看有没有符合的四条边
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const int N = ;
typedef struct aa{
int x, y;
}AA;
AA a[N]; double dis(AA b, AA c)
{
double len = sqrt((b.x - c.x) * (b.x - c.x) + (b.y - c.y) * (b.y - c.y));
return len;
}
int main()
{
int t, num, cnt = ;
cin >> t;
int T = t;
while(T--)
{
for(int i = ; i < ; i++)
{
cin >> a[i].x >> a[i].y;
}
double ll = ;
num = ;
for(int i = ; i < ; i++)
{
for(int j = i+; j < ; j++)
{
double dist = dis(a[i], a[j]);
if(dist == ll)
{
num++;
}
else if(dist < ll)
{
ll = dist;
num = ;
}
}
}
if(num == )
{
if(cnt != t)
cout << "Case " << "" << cnt++ << ":" << endl << "Yes" << endl << endl;
else
cout << "Case " << "" << cnt++ << ":" << endl << "Yes";
}
else
{
if(cnt != t)
cout << "Case " << "" << cnt++ << ":" << endl << "No" << endl << endl;
else
cout << "Case " << "" << cnt++ << ":" << endl << "No";
} }
return ;
}
ZOJ2540 Form a Square的更多相关文章
- [LeetCode] Matchsticks to Square 火柴棍组成正方形
Remember the story of Little Match Girl? By now, you know exactly what matchsticks the little match ...
- Leetcode: Matchsticks to Square && Grammar: reverse an primative array
Remember the story of Little Match Girl? By now, you know exactly what matchsticks the little match ...
- HDU1518 Square(DFS,剪枝是关键呀)
Square Time Limit : 10000/5000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Submi ...
- Facebook Hacker Cup 2014 Qualification Round 竞赛试题 Square Detector 解题报告
Facebook Hacker Cup 2014 Qualification Round比赛Square Detector题的解题报告.单击这里打开题目链接(国内访问需要那个,你懂的). 原题如下: ...
- HDU1518 Square(DFS)
Square Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Su ...
- HDOJ 1518 Square
Square Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Sub ...
- Square
Square TimeLimit: 1 Second MemoryLimit: 32 Megabyte Totalsubmit: 1638 Accepted: 440 Description ...
- HDU-1518 Square(DFS)
Square Time Limit : 10000/5000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Submi ...
- Square(hdu 1511)
题目描述: Problem Description Given a set of sticks of various lengths, is it possible to join them end- ...
随机推荐
- Linux 安装 mysql 转 http://www.cnblogs.com/fnlingnzb-learner/p/5830622.html
到mysql官网下载mysql编译好的二进制安装包,在下载页面Select Platform:选项选择linux-generic,然后把页面拉到底部,64位系统下载Linux - Generic (g ...
- 【Coursera】Technology :Fifth Week(2)
The Ethernet Story Bob Metcalfe Bob 参与了 Xerox 研究项目,着手解决建造一个处处连接个人计算机的架构.当时,他们刚刚完成了 Internet 的开端 -具有 ...
- C# 读取txt文件内容
if (!System.IO.File.Exists(@"E:\\111.txt")) { Console.Write("没有找到文件!"); } System ...
- 肿瘤基因组学数据库终结者:cBioPortal---转载
转载自:http://blog.sciencenet.cn/blog-1509670-1000479.html 随着芯片和高通量测序技术的广泛应用,在肿瘤研究领域积累了越来越多的基因组学数据,特别是像 ...
- Codeforces Beta Round #94 div2 D 优先队列
B. String time limit per test 2 seconds memory limit per test 256 megabytes input standard input out ...
- shell case语句
case 格式 case 值 in 模式1) command1 command2 ... commandN ;; 模式2) command1 command2 ... commandN ;; esac ...
- django QueryDict对象
类的原型:class QueryDict[source] 在HttpRequest对象中,GET和POST属性都是一个django.http.QueryDict的实例.也就是说你可以按本文下面提供的方 ...
- 日志_测试代码_Qt532
1. int LogFile(QString &_str) { QDateTime datetime = QDateTime::currentDateTime();//获取系统现在的时间 QS ...
- RabbitMQ入门_08_所谓的点对点与发布订阅模型
A. JMS 模型 JMS 中定义了点对点和发布订阅两种消息模型,原来以为 AMQP 协议中 direct Exchange 对应点对点模型,topic Exchange 对应发布订阅模型,fanou ...
- js中如何访问对象和数组
js中如何访问对象和数组 一.总结 一句话总结:js访问对象点和中括号,访问数组的话就是中括号 对象 . [] 数组 [] 1.js访问对象的两种方式? . [] 可以使用下面两种方式访问对象的属性和 ...