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
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
Case #1: Parallelogram
Case #2: Rectangle
Case #3: Diamond
Case #4: Square
Case #5: Others

判断 平行四边形 矩形 菱形 正方形

题解:一步步来  先判断是不是平行四边形再判断是不是矩形和菱形  如果既是矩形也是菱形  那么 就是正方形,否则分别判断是矩形 还是菱形。。具体看代码

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

  1. cdoj 93 King's Sanctuary 傻逼几何题

    King's Sanctuary Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/sho ...

  2. King's Sanctuary(简单几何)

    King's Sanctuary Time Limit: 1000 ms Memory Limit: 65535 kB Solved: 111 Tried: 840 Submit Status Bes ...

  3. BZOJ 1087: [SCOI2005]互不侵犯King [状压DP]

    1087: [SCOI2005]互不侵犯King Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 3336  Solved: 1936[Submit][ ...

  4. [bzoj1087][scoi2005]互不侵犯king

    题目大意 在N×N的棋盘里面放K个国王,使他们互不攻击,共有多少种摆放方案.国王能攻击到它上下左右,以及左上 左下右上右下八个方向上附近的各一个格子,共8个格子. 思路 首先,搜索可以放弃,因为这是一 ...

  5. King's Quest —— POJ1904(ZOJ2470)Tarjan缩点

    King's Quest Time Limit: 15000MS Memory Limit: 65536K Case Time Limit: 2000MS Description Once upon ...

  6. 【状压DP】bzoj1087 互不侵犯king

    一.题目 Description 在N×N的棋盘里面放K个国王,使他们互不攻击,共有多少种摆放方案.国王能攻击到它上.下.左.右,以及左上.左下.右上.右下八个方向上附近的各一个格子,共8个格子. I ...

  7. ZOJ 2334 Monkey King

    并查集+左偏树.....合并的时候用左偏树,合并结束后吧父结点全部定成树的根节点,保证任意两个猴子都可以通过Find找到最厉害的猴子                       Monkey King ...

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

  9. BZOJ-1087 互不侵犯King 状压DP+DFS预处理

    1087: [SCOI2005]互不侵犯King Time Limit: 10 Sec Memory Limit: 162 MB Submit: 2337 Solved: 1366 [Submit][ ...

随机推荐

  1. Saving James Bond - Hard Version

    07-图5 Saving James Bond - Hard Version(30 分) This time let us consider the situation in the movie &q ...

  2. [jzoj5073 GDOI2017第二轮模拟] 影魔

    Description 影魔,奈文摩尔,据说有着一个诗人的灵魂.事实上,他吞噬的诗人灵魂早已成千上万.千百年来,他收集了各式各样的灵魂,包括诗人.牧师.帝王.乞丐.奴隶.罪人,当然,还有英雄.每一个灵 ...

  3. 使用PL/SQL将sql脚本数据导入数据库

    一. PL/SQL登录到数据库,使用tools工具进行导入.使用plsql登录到需要导入数据的数据库.点击工具栏上[tools]--[Import tables] 二.commit;

  4. spring的IOC底层原理

    我们调用一个类的方法,首先是User user=new  User(),对象调用这个方法,user.add(),这种方法有一个缺陷就是代码的耦合度太高,比如你的servlet调用User类里的方法,需 ...

  5. maven+Hibernate+mysql环境搭建

    项目结构图如下 一,首先是添加依赖pom.xml <?xml version="1.0" encoding="UTF-8"?> <projec ...

  6. BZOJ1733: [Usaco2005 feb]Secret Milking Machine 神秘的挤奶机

    n<=200个点m<=40000条边无向图,求   t次走不经过同条边的路径从1到n的经过的边的最大值   的最小值. 最大值最小--二分,t次不重边路径--边权1的最大流. #inclu ...

  7. HDU 1402 大数乘法 FFT、NTT

    A * B Problem Plus Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  8. hdu——3861 The King’s Problem

    The King’s Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  9. Eclipse注释模板配置

    不过感觉作用不大,因为@date这些不是标准的Java注释.

  10. intelliJ IDEA工具快捷键

    F9            resume programe 恢复程序 Alt+F10        show execution point 显示执行断点 F8            Step Ove ...