cdoj 93 King's Sanctuary 傻逼几何题
King's Sanctuary
Time Limit: 20 Sec Memory Limit: 256 MB
题目连接
http://acm.uestc.edu.cn/#/problem/show/93
Description
The king found his adherents were building four sanctuaries for him. He is interested about the positions of the sanctuaries and wants to know whether they would form a parallelogram, rectangle, diamond, square or anything else.
Input
The first line of the input is T(1≤T≤1000), which stands for the number of test cases you need to solve. Each case contains four lines, and there are two integers in each line, which shows the position of the four sanctuaries. And it is guaranteed that the positions are given clockwise. And it is always a convex polygon, if you connect the four points clockwise.
Output
For every test case, you should output Case #t: first, where t indicates the case number and counts from 1, then output the type of the quadrilateral.
Sample Input
5
0 0
1 1
2 1
1 0
0 0
0 1
2 1
2 0
0 0
2 1
4 0
2 -1
0 0
0 1
1 1
1 0
0 0
1 1
2 1
3 0
Sample Output
Case #1: Parallelogram
Case #2: Rectangle
Case #3: Diamond
Case #4: Square
Case #5: Others
HINT
题意
题解:
给你4个点,让你判断是正方形,还是菱形,还是矩形,还是平行四边形
乱搞就好了 = =
代码:
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath> using namespace std; int T, x[], y[]; bool Parallelogram()
{
int a = (y[] - y[]) * (x[] - x[]);
int b = (x[] - x[]) * (y[] - y[]);
if(a != b) return false;
a = (x[] - x[]) * (y[] - y[]);
b = (x[] - x[]) * (y[] - y[]);
return a == b;
} bool Rectangle()
{
int a = (x[] - x[]) * (x[] - x[]) + (y[] - y[]) * (y[] - y[]);
int b = (x[] - x[]) * (x[] - x[]) + (y[] - y[]) * (y[] - y[]);
return a == b;
} bool Diamond()
{
int a = (y[] - y[]) * (y[] - y[]);
int b = (x[] - x[]) * (x[] - x[]);
return a == -b;
} int main()
{
scanf("%d", &T);
for(int ca = ; ca <= T; ca++)
{
int i, j;
for(i = ; i < ; i++)
{
scanf("%d %d", &x[i], &y[i]);
}
printf("Case #%d: ", ca);
for(i = ; i < ; i++)
{
for(j = i + ; j < ; j++)
{
if(x[i] == x[j] && y[i] == y[j])
break;
}
if(j != ) break;
}
if(i != ) puts("Others");
else
{
bool tag, tag1;
tag = Parallelogram();
if(tag == false) {puts("Others");}
else
{
tag = Rectangle();
tag1 = Diamond();
if(tag == false && tag1 == false) puts("Parallelogram");
else if(tag == true && tag1 == true) puts("Square");
else if(tag == true) puts("Rectangle");
else if(tag1 == true) puts("Diamond");
}
}
}
return ;
}
cdoj 93 King's Sanctuary 傻逼几何题的更多相关文章
- King's Sanctuary(简单几何)
King's Sanctuary Time Limit: 1000 ms Memory Limit: 65535 kB Solved: 111 Tried: 840 Submit Status Bes ...
- 傻逼Eclipse笔记
Eclipse 这么傻逼的工具,还有人用,真是奇了怪了. Invalid project description 我想打开SVN 的代码 ,别让我拷到别的地方,怎么破? 正确答案是: 删除 Eclip ...
- BZOJ-1625 宝石手镯 01背包(傻逼题)
傻逼题,懒得打,复制蛋蛋的.. 1625: [Usaco2007 Dec]宝石手镯 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 1076 Solved: ...
- Codeforces Gym 100338I TV Show 傻逼DFS,傻逼题
Problem I. TV ShowTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest ...
- BZOJ 2222: [Cqoi2006]猜数游戏【神奇的做法,傻逼题,猜结论】
2222: [Cqoi2006]猜数游戏 Time Limit: 20 Sec Memory Limit: 259 MBSubmit: 604 Solved: 260[Submit][Status ...
- [BZOJ]4644: 经典傻逼题
某天我觉得一切题目都是那么不可做,于是百度了一下"傻逼题"-- 题目大意:对于图中的任意一个点集(可以为空或者全集),所有恰好有一个端点在这个点集中的边组成的集合被称为割.一个割的 ...
- OI中常犯的傻逼错误总结
OI中常犯的傻逼错误总结 问题 解决方案 文件名出错,包括文件夹,程序文件名,输入输出文件名 复制pdf的名字 没有去掉调试信息 调试时在后面加个显眼的标记 数组开小,超过定义大小,maxn/ ...
- Expo大作战(三十一)--expo sdk api之Payments(expo中的支付),翻译这篇文章傻逼了,完全不符合国内用户,我只负责翻译大家可以略过!
简要:本系列文章讲会对expo进行全面的介绍,本人从2017年6月份接触expo以来,对expo的研究断断续续,一路走来将近10个月,废话不多说,接下来你看到内容,讲全部来与官网 我猜去全部机翻+个人 ...
- 【题解】 bzoj2435: [Noi2011]道路修建 (傻逼题)
bzoj2435,懒得复制,戳我戳我 Solution: 模拟即可(有点傻逼啊 Code: //It is coded by Ning_Mew on 5.13 #include<bits/std ...
随机推荐
- [转]linux系统的7种运行级别
转自:http://blog.chinaunix.net/uid-22746363-id-383989.html Linux系统有7个运行级别(runlevel)运行级别0:系统停机状态,系统默认运行 ...
- 基于OSGI.Net的图形界面系统
在2013年的十月份有幸接触了osgi.net和iopenworks的创始人,了解和学习的插件式开发,开始了后台数据的处理生涯. 第一个有图形界面的系统——智能农业的环境监测系统,其实在这个系统中所有 ...
- 使用Go开发一个简单的服务器程序
最近有个小项目,需要一个简单的后台程序来支撑,本来想用Nodejs来做,但是由于本人js一直很菜,并且很讨厌callback,虽然我也很喜欢异步模型,但我一直都觉得JS是反人类的.后台就用了go处理, ...
- CentOS6.5(带图形安装)在使用过程中遇到的一些网络问题迷惑
比如,经常会遇到这样的问题************************** [root@SourceCompiler local]# pwd/usr/local[root@SourceCompil ...
- Java之对象池
单例模式是限制了一个类只能有一个实例,对象池模式则是限制一个类实例的个数.对象池类就像是一个对象管理员,它以Static列表(也就是装对象的池子)的形式存存储某个实例数受限的类的实例,每一个实例还要加 ...
- 自定义元素 – 在 HTML 中定义新元素
本文翻译自 Custom Elements: defining new elements in HTML,在保证技术要点表达准确的前提下,行文风格有少量改编和瞎搞. 原译文地址 本文目录 引言 用时髦 ...
- <转载>浅谈C/C++的浮点数在内存中的存储方式
C/C++浮点数在内存中的存储方式 任何数据在内存中都是以二进制的形式存储的,例如一个short型数据1156,其二进制表示形式为00000100 10000100.则在Intel CPU架构的系统中 ...
- ARP防火墙绑定网关MAC地址预防ARP攻击和P2P终结者
[故障原理] 要了解故障原理,我们先来了解一下ARP协议. 在局域网中,通过ARP协议来完成IP地址转换为第二层物理地址(即MAC地址)的.ARP协议对网络安全具有重要的意义.通过伪造IP地址和M ...
- printf输出字符串的一些格式
1. 原样输出字符串: printf("%s", str); 2. 输出指定长度的字符串, 超长时不截断, 不足时右对齐: printf("%Ns" ...
- Linux应用总结:自动删除n天前日志
linux是一个很能自动产生文件的系统,日志.邮件.备份等.虽然现在硬盘廉价,我们可以有很多硬盘空间供这些文件浪费,让系统定时清理一些不需要的文件很有一种爽快的事情.不用你去每天惦记着是否需要清理日志 ...