King's Sanctuary

Time Limit: 1000 ms Memory Limit: 65535 kB Solved: 111 Tried: 840

Submit

Status

Best Solution

Back

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

 

Source

 

Sichuan State Programming Contest 2012

步骤:1.判断是否平行四边形,不是则为others,是则执行2;2.判断是否菱形,是否长方形,都是则为正方形,都不是则为平行四边形,其一是另一否,则是菱形或长方形。

 #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 ;
}

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. Python下opencv使用笔记(二)(简单几何图像绘制)

    简单几何图像一般包含点.直线.矩阵.圆.椭圆.多边形等等.首先认识一下opencv对像素点的定义. 图像的一个像素点有1或者3个值.对灰度图像有一个灰度值,对彩色图像有3个值组成一个像素值.他们表现出 ...

  3. UESTC93 King's Sanctuary

    King's Sanctuary Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) ...

  4. Codeforces 935 简单几何求圆心 DP快速幂求与逆元

    A #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #def ...

  5. 简单几何(线段相交) POJ 2653 Pick-up sticks

    题目传送门 题意:就是小时候玩的一种游戏,问有多少线段盖在最上面 分析:简单线段相交,队列维护当前最上的线段 /******************************************** ...

  6. osg for android (一) 简单几何物体的加载与显示

    1. 首先需要一个OSG for android的环境. (1).NDK 现在Eclipse 对NDK已经相当友好了,已经不需要另外cygwin的参与,具体可以参考 Android NDK开发篇(一) ...

  7. HDU 6206 青岛网络赛1001 高精度 简单几何

    给出的数据1e12规模,常规判点是否在圆范围内肯定要用到半径,求得过程中无法避免溢出,因此用JAVA自带的浮点大数运算,和个ZZ一样比赛中eclipse出现问题,而且太久没写JAVA语法都不清楚变量忘 ...

  8. CodeForces 703C Chris and Road (简单几何)

    题意:有一个n边形的汽车向以速度v向x轴负方向移动,给出零时时其n个点的坐标.并且有一个人在(0,0)点,可以以最大速度u通过w宽的马路,到达(0,w)点.现在要求人不能碰到汽车,人可以自己调节速度. ...

  9. Jack Straws POJ - 1127 (简单几何计算 + 并查集)

    In the game of Jack Straws, a number of plastic or wooden "straws" are dumped on the table ...

随机推荐

  1. 遇到Intel MKL FATAL ERROR: Cannot load libmkl_avx2.so or libmkl_def.so问题的解决方法

    运行一个基于tensorflow的模型时,遇到Intel MKL FATAL ERROR: Cannot load libmkl_avx2.so or libmkl_def.so问题. 解决方法:打开 ...

  2. HDU 5269 ZYB loves Xor I Trie树

    题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5269 bc:http://bestcoder.hdu.edu.cn/contests/con ...

  3. CentOS 7 网卡命名修改为eth0格式

    Linux 操作系统的网卡设备的传统命名方式是 eth0.eth1.eth2等,而 CentOS7 提供了不同的命名规则,默认是基于固件.拓扑.位置信息来分配.这样做的优点是命名全自动的.可预知的,缺 ...

  4. Java实现简单的RPC框架(美团面试)

    一.RPC简介 RPC,全称为Remote Procedure Call,即远程过程调用,它是一个计算机通信协议.它允许像调用本地服务一样调用远程服务.它可以有不同的实现方式.如RMI(远程方法调用) ...

  5. ios 中不new Date 的格式 不支持年月日 以‘-’ 分割的格式

    new Date("2018-1-5") 在 ios 中显示 invalid date - 换做 / 则可以顺利显示 new Date("2018/1/5")

  6. .net 下SSE使用

    HTML5有一个Server-Sent Events(SSE)功能,允许服务端推送数据到客户端.(通常叫数据推送),基于数据推送是这样的,当数据源有新数据,它马上发送到客户端,不需要等待客户端请求.这 ...

  7. 【刷题】BZOJ 4196 [Noi2015]软件包管理器

    Description Linux用户和OSX用户一定对软件包管理器不会陌生.通过软件包管理器,你可以通过一行命令安装某一个软件包,然后软件包管理器会帮助你从软件源下载软件包,同时自动解决所有的依赖( ...

  8. Mybatis笔记五:Mybatis的全局配置文件Configuration.xml讲解

    从 XML 中构建 SqlSessionFactory 每个基于Mybatis应用都是以一个SqlSessionFactory实例为中心.SqlSessionFactory实例可以由SqlSessio ...

  9. unity3d点击屏幕选中物体

    原文  http://blog.csdn.net/mycwq/article/details/19906335 前些天接触unity3d,想实现点击屏幕选中物体的功能.后来研究了下,实现原理就是检测从 ...

  10. 洛谷 P2530 [SHOI2001]化工厂装箱员 解题报告

    P2530 [SHOI2001]化工厂装箱员 题目描述 118号工厂是世界唯一秘密提炼锎的化工厂,由于提炼锎的难度非常高,技术不是十分完善,所以工厂生产的锎成品可能会有3种不同的纯度,A:100%,B ...