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- ...
随机推荐
- [AtCoder ARC061F]Card Game for Three 组合数好题
题目链接 总结:组合数 这$F$题好难啊...只会部分分做法,下面两个方法都是部分分做法.满分做法我去看看...会的话就补一下 部分分做法 方法1: 首先$A$能赢的条件很明显,假设在所有的牌里面取出 ...
- vuejs全局api概念
什么是全局API? 全局API并不在构造器里,而是先声明全局变量或者直接在Vue上定义一些新功能,Vue内置了一些全局API,比如我们今天要学习的指令Vue.directive.说的简单些就是,在构造 ...
- 【TCP/IP详解 卷一:协议】第十一章 UDP 用户数据报协议
11.1 引言 UDP 是一个简单的 面向数据报 的运输层协议:进程的每个 输出操作 都正好产生一个 UDP数据报,并且组装成一份待发送的IP数据报. 这与 TCP 不一样,它是 面向流字符 的协议, ...
- 详解一下 javascript 中的比较
翻译自:http://www.ecma-international.org/ecma-262/5.1/#sec-11.9.3 在JS中的关系比较(Relational Comparison)运算,指的 ...
- zepto点透解决思路
首先看几个链接, http://blog.youyo.name/archives/zepto-tap-click-through-research.html youyo的分析 http://softw ...
- PHP概率,抽奖
随机数,游标卡尺. 一个大饼,随机到哪个坑里,就中哪个奖. 大转盘! 公平公正! // 获取锦鲤 public function getGoldPig() { $pig_gift_bag = [ [ ...
- MongoDB(课时19 数据删除)
3.4.4 删除数据 在MongoDB里面删除数据使用“remove()”.但是这个函数有两个可选项: 删除条件:满足条件的数据被删除. 只删除一个数据:设置为true或者是1表示只删除一个. 范例: ...
- JavaMai——邮箱验证用户注册
这篇文章简单的模拟了网上利用邮箱激活用户注册这样的一个功能 1. 呈现给用户的注册界面:(为了简单起见,就剩下两个输入域,邮箱和昵称) <%@ page language="java& ...
- 在线客服 分享 qq 一键加好友 一键入群
1.在线客服 <a href="tencent://message/?uin=qqnum&Site=&menu=yes">qq客服</a> ...
- 音视频学习系列第(三)篇---wav文件的存储和解析
音视频系列 什么是wav wav是一种无损的音频文件格式,wav文件有两部分,第一部分是文件头,记录一些重要的参数信息,如音频的采样率,通道数,数据位宽,第二部分是数据部分,数据部分可以是PCM,也可 ...