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][ ...
随机推荐
- cs229_part1
开篇题 这个系列的文章主要参考cs229课程的内容,按照自己的思路和其他课程与书籍方式梳理下来,可能顺序和内容都与cs229有点不一样,但是参考内容我都会附在最后.而且这个系列主要讲个人的理解不想太多 ...
- C#中对泛型List进行分组输出元素
背景:在输出列表时,往往需要按照某一字段进行分组,比如在输出城市列表时,按照首字母进行分组,输出学生列表时,按照年级进行分组,然后再对分组的结果按照其他的字段进行排序. 如存在以下STU学生类,代码如 ...
- 洛谷 P1434 [SHOI2002]滑雪
这道题适合记忆化练手 毕竟总有些大佬虐题. 这个题有几个剪枝 1.记忆化 这个不用多说了吧 剪枝就是 如果 当前点到下面一个点的目前下降的高度+1 小于 下面那个点 能下降的高度 那么反过来,这个点不 ...
- 【转】SQL Server 2008 新数据类型
概览: 新日期和时间数据类型 代表在层次结构中的位置 用于处理空间数据的两种模型 在全球经济环境下开展业务这一趋势越来越要求各公司使用新型的数据.应用程序以及复杂的计算.SQL Server 2008 ...
- Vmware改成bridge方式联网
1.在使用桥接之前,先在真机的'更改适配器设置中'禁用vmnet1和vmnet8 2.在VMware中定义一个桥接器 3.设置这个Linux虚拟机使用前一个步骤定义的桥接器--进入桥接器选择界面 4. ...
- 大数据学习——采集文件到HDFS
采集需求:比如业务系统使用log4j生成的日志,日志内容不断增加,需要把追加到日志文件中的数据实时采集到hdfs 根据需求,首先定义以下3大要素 l 采集源,即source——监控文件内容更新 : ...
- .net中的协变和逆变
百度:委托中的协变和逆变. 百度:.net中的协变和逆变. 协变是从子类转为父类. 逆变是从父类到子类. 这样理解不一定严谨或者正确.需要具体看代码研究.
- 高精度模板(From JCVB)
#include<cstdio> #include<algorithm> #include<cstring> #include<iostream> #i ...
- C#的特性学习草稿
原文发布时间为:2008-11-22 -- 来源于本人的百度文章 [由搬家工具导入] 举个简单的例子: 先定义个特性 从Attribute继承,并标明用法 [AttributeUsage(Attrib ...
- hdu 5195 DZY Loves Topological Sorting BestCoder Round #35 1002 [ 拓扑排序 + 优先队列 || 线段树 ]
传送门 DZY Loves Topological Sorting Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131 ...