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- ...
随机推荐
- 马尔科夫随机场模型(MRF-Markov Random Field)
原文: http://blog.sina.com.cn/s/blog_92c398b00102vs3q.html 马尔科夫过程 隐马尔科夫过程 与马尔科夫相比,隐马尔可夫模型则是双重随机过程,不 ...
- 解决Ubuntu14.04 下 E: Encountered a section with no Package: header 问题
参考: ubuntu-E:Encountered a section with no Package: header的解决办法 解决Ubuntu14.04 下 E: Encountered a sec ...
- zepto点透解决思路
首先看几个链接, http://blog.youyo.name/archives/zepto-tap-click-through-research.html youyo的分析 http://softw ...
- React Native 之轮播图swiper组件
注释:swiper组件是第三方组件 所以在使用之前应该先在命令行安装,然后将第三方的模块引入(第三方模块地址:https://github.com/leecade/react-native-swipe ...
- 关于Mybatis 的 Mapped Statements collection does not contain value for 异常 解决方案
查看堆栈信息: at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:595) at org.apac ...
- Java中一种无意识的递归
来自: Java编程思想P287 public class Main { /** * @param args */ @Override public String toString() { retur ...
- mybatis generator插件系列--lombok插件 (减少百分之九十bean代码)
经常使用mybatis generator生成代码的你 有没有因为生成的getter/setter而烦恼呢? 有没有生成后又手动加toString/hashCode/Equals方法呢? 有没有改一个 ...
- python 集合的比较
setx = set(["apple", "mango"]) sety = set(["mango", "orange" ...
- python 元组元素计数
#create a tuple tuplex = , , , , , , , , print(tuplex) #return the number of times it appears in the ...
- linux 系统调用号表
位于 /usr/include/asm/unistd.h 由于我是64位系统,所以有一些额外的东西.我的这个文件为下文 #ifndef _ASM_X86_UNISTD_H #define _ASM_X ...