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][ ...
随机推荐
- Leetcode 321.拼接最大数
拼接最大数 给定长度分别为 m 和 n 的两个数组,其元素由 0-9 构成,表示两个自然数各位上的数字.现在从这两个数组中选出 k (k <= m + n) 个数字拼接成一个新的数,要求从同一个 ...
- firefox自动化测试的常用插件
1.firebug 2.firepath 3.firefinder 5.WebDriver Element Locator 提供多种语言的xpath路径
- HH的项链(codevs 2307)
题目描述 Description HH有一串由各种漂亮的贝壳组成的项链.HH相信不同的贝壳会带来好运,所以每次散步完后,他都会随意取出一段贝壳,思考它们所表达的含义.HH不断地收集新的贝壳,因此,他的 ...
- hdu2294:Pendant
T<=10组数据问K<=30种珠子每种n<=1e9串成1~n长度的序列共有多少种,mod1234567891. 方程没想到.矩阵不会推.很好. f[i][j]--长度i,j种珠子方案 ...
- usort 使用(转载)
private function arrCmp($a,$b){ if($a['day_time'] == $b['day_time']){ return 0; } return($a['day_ti ...
- Python()- 面向对象三大特性----多态
多态: python 生来支持多态白话:一种事物的多种形态 (动物可以继承给狗,也可以继承给猫) class Animal: pass class Dog(Animal): def attack(se ...
- 2016 ACM/ICPC 区域赛(北京) E 题 bfs
https://vjudge.net/problem/UVALive-7672 题意 输入一个五位数n 问由12345变到n的操作最少次数 不可达输出-1 有三种操作 1.交换相邻的位置 次数不 ...
- 牛客网暑期ACM多校训练营(第九场) A题 FWT
链接:https://www.nowcoder.com/acm/contest/147/A来源:牛客网 Niuniu has recently learned how to use Gaussian ...
- Java加载配置文件类
/** * 对应配置文件类, */ package com.up72.parkSys.ThirdParty; import java.io.IOException;import java.io.In ...
- Linux 特殊文档说明
目录 /usr/share/man 目录 /usr/share/doc /etc/passwd 文件 /etc/shadow 文件 /etc/group 文件 /usr/share/man 目录 当我 ...