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- ...
随机推荐
- System.ConfigurationManager类用于对配置文件的读取
http://blog.csdn.net/ligenyingsr/article/details/54095986 System.ConfigurationManager类用于对配置文件的读取.其具有 ...
- [Shiro] - 基于URL配置动态权限
基于shiro进阶 更改了数据库表 之前的PageController是通过@RequiresPermissions和@RequiresRoles进行是否有权限/是否有角色的判定调用@RequestM ...
- 使用InputStreamReader读入,使用OutputStreamWriter写出,将一首诗按行重写?
https://www.processon.com/view/link/5b1a3880e4b00490ac8f5f40 改善后: (可将不管一行有几个字时的不规律的文本,按行倒写) package ...
- Unity3D学习笔记(二十四):MVC框架
MVC:全名是Model-View-Controller View(视图层 - 顶层) Controller(控制层 - 中层) Model(数据层 - 底层) View(视图层) 说明:展现给玩家的 ...
- 棋盘覆盖问题(算法分析)(Java版)
1.问题描述: 在一个2k×2k个方格组成的棋盘中,若有一个方格与其他方格不同,则称该方格为一特殊方格,且称该棋盘为一个特殊棋盘.显然特殊方格在棋盘上出现的位置有种情形.因而对任何 k≥0,有4k种不 ...
- hihoCoder 1513 小Hi的烦恼
hihoCoder 1513 小Hi的烦恼 思路: 用bitset判断交集个数 代码: #include<bits/stdc++.h> using namespace std; #defi ...
- Codeforces 913C - Party Lemonade
913C - Party Lemonade 思路:对于第i个话费cost[i],取min(cost[i],2*cost[i-1]),从前往后更新,这样就可以保证第n个的话费的性价比最高,那么从最高位开 ...
- Google chrome浏览器打不开网页,显示ERR_Failed...等问题的解决方法
新装好的win7系统,打开Google浏览器,显示网页可能暂时无法连接,或者它已永久性的移动到了新地址.在网络搜索很多资料,发现解决方法如下,亲测成功. 原因,该服务依赖的TCP/IP 协议有问题. ...
- 20170813pptVBA批量插入图片
Sub AddSldIn() Dim Pre As Presentation Dim NewSld As Slide Set Pre = Application.ActivePresentation ...
- python-day9-循环嵌套
练习:99乘法表: # for line in range(1,10): #line=2# for row in range(1,line+1):# print('%s*%s=%s' %(line,r ...