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的更多相关文章

  1. [LeetCode] Matchsticks to Square 火柴棍组成正方形

    Remember the story of Little Match Girl? By now, you know exactly what matchsticks the little match ...

  2. 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 ...

  3. HDU1518 Square(DFS,剪枝是关键呀)

    Square Time Limit : 10000/5000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submi ...

  4. Facebook Hacker Cup 2014 Qualification Round 竞赛试题 Square Detector 解题报告

    Facebook Hacker Cup 2014 Qualification Round比赛Square Detector题的解题报告.单击这里打开题目链接(国内访问需要那个,你懂的). 原题如下: ...

  5. HDU1518 Square(DFS)

    Square Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Su ...

  6. HDOJ 1518 Square

    Square Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Sub ...

  7. Square

    Square TimeLimit: 1 Second   MemoryLimit: 32 Megabyte Totalsubmit: 1638   Accepted: 440 Description ...

  8. HDU-1518 Square(DFS)

    Square Time Limit : 10000/5000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submi ...

  9. Square(hdu 1511)

    题目描述: Problem Description Given a set of sticks of various lengths, is it possible to join them end- ...

随机推荐

  1. [BZOJ1044][HAOI2008]木棍分割 二分 + 单调队列优化dp + 滚动数组优化dp

    Description 有n根木棍, 第i根木棍的长度为Li,n根木棍依次连结了一起, 总共有n-1个连接处. 现在允许你最多砍断m个连接处, 砍完后n根木棍被分成了很多段,要求满足总长度最大的一段长 ...

  2. mybatis的注解开发之三种动态sql

    脚本sql XML配置方式的动态SQL我就不讲了,有兴趣可以自己了解,下面是用<script>的方式把它照搬过来,用注解来实现.适用于xml配置转换到注解配置 @Select(" ...

  3. Unity3D学习笔记(二十一):InputFiled、Dropdown、Scroll Rect、Mask

    InputFiled组件(输入框) Text Component(显示内容):显示输入内容的Text的组件 Text(输入内容):输入的文本内容 Character Limit:字符数量限值,0是无限 ...

  4. Windows下搭建FTP服务器

    一.什么是ftp? FTP 是File Transfer Protocol(文件传输协议)的英文简称,而中文简称为“文传协议”.用于Internet上的控制文件的双向传输.同时,它也是一个应用程序(A ...

  5. UVa 10163 仓库守卫

    https://vjudge.net/problem/UVA-10163 题意: 有n个仓库,m个管理员,每个管理员有一个能力值P(接下来的一行有m个数,表示每个管理员的能力值) 每个仓库只能由一个管 ...

  6. mvc ---- ajax 提交过来的Json格式如何处理(解析)

    前台传过来的不是一个对象,而是一个Json字符串怎么办 ? 如: {","contents":"<p>lsdfjlsdjflsdf</p> ...

  7. python字典按照value进行排序.bak

    先说几个解决的方法,具体的有时间再细说 d = {'a':1,'b':4,'c':2} 字典是这个,然后要对字典按照value进行排序 方法一: sorted(d.items(),key = lamb ...

  8. spring boot 开发 提交form表单出错

    提交表单时,字段有的没有值,springboot 会报错. org.springframework.validation.BindException: org.springframework.vali ...

  9. WPF StoryBoard用法

    时间:2011-06-15 21:26来源:百度空间 作者:shichen4 点击: 次 StoryBoard使用,Xaml转cs代码 Canvas.Triggers EventTriggerRout ...

  10. Non-parseable POM 解决方法

     两个build放在一起当然不行,把它们类似这样的合并起来.