UESTC93 King's Sanctuary
King's Sanctuary
Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others)
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 TT(1≤T≤10001≤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 tt indicates the case number and counts from 11, then output the type of the quadrilateral.
Sample input and output
Sample Input | Sample Output |
---|---|
5 |
Case #1: Parallelogram |
判断 平行四边形 矩形 菱形 正方形
题解:一步步来 先判断是不是平行四边形再判断是不是矩形和菱形 如果既是矩形也是菱形 那么 就是正方形,否则分别判断是矩形 还是菱形。。具体看代码
/* ***********************************************
Author :guanjun
Created Time :2016/7/15 15:30:29
File Name :1.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 0x3f3f3f3f
#define maxn 10010
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << ;
const double eps=1e-;
using namespace std;
priority_queue<int,vector<int>,greater<int> >pq;
struct Node{
int x,y;
};
struct cmp{
bool operator()(Node a,Node b){
if(a.x==b.x) return a.y> b.y;
return a.x>b.x;
}
}; bool cmp(int a,int b){
return a>b;
}
int x[];
int y[];
bool judge_Parallelogram(){
//1,2 4,3
int a=(x[]-x[])*(y[]-y[])-(x[]-x[])*(y[]-y[]);
if(a!=)return ;
a=(x[]-x[])*(y[]-y[])-(x[]-x[])*(y[]-y[]);
if(a!=)return ;
return ;
}
bool judge_Rectangle(){
int a=(x[]-x[])*(x[]-x[])+(y[]-y[])*(y[]-y[]);
int b=(x[]-x[])*(x[]-x[])+(y[]-y[])*(y[]-y[]);
if(a==b)return ;
return ;
}
bool judge_Diamond(){
int a=(x[]-x[])*(x[]-x[])+(y[]-y[])*(y[]-y[]);
int b=(x[]-x[])*(x[]-x[])+(y[]-y[])*(y[]-y[]);
if(a==b)return ;
return ;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int t;
cin>>t;
int cas=;
while(t--){
for(int i=;i<=;i++){
cin>>x[i]>>y[i];
}
printf("Case #%d: ",++cas);
if(judge_Parallelogram()){
if(judge_Rectangle()&&judge_Diamond()){
puts("Square");
}
else if(judge_Diamond()){
puts("Diamond");
}
else if(judge_Rectangle()){
puts("Rectangle");
}
else puts("Parallelogram");
}
else puts("Others"); }
return ;
}
UESTC93 King's Sanctuary的更多相关文章
- cdoj 93 King's Sanctuary 傻逼几何题
King's Sanctuary Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/sho ...
- King's Sanctuary(简单几何)
King's Sanctuary Time Limit: 1000 ms Memory Limit: 65535 kB Solved: 111 Tried: 840 Submit Status Bes ...
- BZOJ 1087: [SCOI2005]互不侵犯King [状压DP]
1087: [SCOI2005]互不侵犯King Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 3336 Solved: 1936[Submit][ ...
- [bzoj1087][scoi2005]互不侵犯king
题目大意 在N×N的棋盘里面放K个国王,使他们互不攻击,共有多少种摆放方案.国王能攻击到它上下左右,以及左上 左下右上右下八个方向上附近的各一个格子,共8个格子. 思路 首先,搜索可以放弃,因为这是一 ...
- King's Quest —— POJ1904(ZOJ2470)Tarjan缩点
King's Quest Time Limit: 15000MS Memory Limit: 65536K Case Time Limit: 2000MS Description Once upon ...
- 【状压DP】bzoj1087 互不侵犯king
一.题目 Description 在N×N的棋盘里面放K个国王,使他们互不攻击,共有多少种摆放方案.国王能攻击到它上.下.左.右,以及左上.左下.右上.右下八个方向上附近的各一个格子,共8个格子. I ...
- ZOJ 2334 Monkey King
并查集+左偏树.....合并的时候用左偏树,合并结束后吧父结点全部定成树的根节点,保证任意两个猴子都可以通过Find找到最厉害的猴子 Monkey King ...
- ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 K. King’s Rout
K. King's Rout time limit per test 4 seconds memory limit per test 512 megabytes input standard inpu ...
- BZOJ-1087 互不侵犯King 状压DP+DFS预处理
1087: [SCOI2005]互不侵犯King Time Limit: 10 Sec Memory Limit: 162 MB Submit: 2337 Solved: 1366 [Submit][ ...
随机推荐
- vs2010 C# 如何将类做成DLL 再从另一个项目中使用这个类
vs2010 C# 如何将类做成DLL 再从另一个项目中使用这个类 2011-10-20 12:00 486人阅读 评论(0) 收藏 举报 一.将类做成DLL 方法一: 你可以通过在命令行下用命令将以 ...
- 【Kubernetes】Kubernetes的Service外部访问方式:NodePort和LoadBalancer
Kubernetes的Pod的寿命是有限的,它们不会复活,因此尽管每个Pod都有自己的IP地址,但是这些IP地址是不可靠的,会随着Pod的消亡而消失. 这就带来一个问题,如果一些Pod的集合(称之为b ...
- php5.5编译安装
系统环境:centos6.5PHP包:5.5.15https://wiki.swoole.com/wiki/page/177.html下载 PHP 源码包wget http://cn2.php.net ...
- Python的另一种开发环境--Anaconda中的Spyder
本文作者LucyGill,转载请注明出处(虽然我觉得并不会有人转载). 刚开始学Python的时候,我用的是其自带的idle(安装Python后,在开始菜单里可以找到),后来发现在eclipse中设置 ...
- apache cgi 模块安装
apache安装,请参照:http://httpd.apache.org/docs/2.4/ 安装系统: Fedora release 21 (Twenty One) (x64) 版本:Server ...
- HDU 1024 Max Sum Plus Plus【DP,最大m子段和】
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1024 题意: 给定序列,给定m,求m个子段的最大和. 分析: 设dp[i][j]为以第j个元素结尾的 ...
- JavaOne Online Hands-on Labs
http://www.oracle.com/technetwork/java/index-156938.html
- 海康设备网络SDK 编程
http://www.cnblogs.com/qtblog/p/5366276.html http://www.hikvision.com/Cn/download_more_401.html
- Oracle计算时间差
Oracle计算时间差表达式 --获取两时间的相差豪秒数 select ceil((To_date('2008-05-02 00:00:00' , 'yyyy-mm-dd hh24-mi-ss') - ...
- guava缓存设置return null一直报错空指针
guava缓存设置return null一直报错空指针 因为缓存不允许返回为空