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. Linux发行版本应用场景

    如果你是一个Linux爱好者,想选择一个桌面系统,并且既不想用盗版,又不想花太多钱购买商业系统软件,那么可以选择Ubuntu桌面系统.如果你需要服务器端的Linux系统,想用一个比较稳定的服务器系统, ...

  2. GIT团队实战

    项目要求 组长博客 遇到的困难及解决办法 组员1(组长):王彬 遇到的困难  在团队任务分工的时候没有充分照顾到所有人,导致队员们的工作量不均. 现场编程时间不够 解决办法 在此对组员们表示抱歉,由于 ...

  3. Sql server 中关闭ID自增字段(SQL取消ID自动增长)

    sql server在导入数据的时候,有时候要考虑id不变,就要先取消自动增长再导入数据,导完后恢复自增. 比如网站改版从旧数据库导入新数据库,数据库结构不相同,可能会使用insert into xx ...

  4. DNS测试工具的使用(了解)

    dig命令, host命令, nslookup命令,rndc命令 dig命令(直接测试DNS性能,不会查询/etc/hosts文件) dig [-t RR_TYPE] name [@SERVER] [ ...

  5. Kotlin在处理GET和POST请求的数据问题

    1.网络请求获取到的数据流处理 java写法 BufferedReader br = new BufferedReader(new InputStreamReader(in, "utf-8& ...

  6. PAT 甲级 1063 Set Similarity

    https://pintia.cn/problem-sets/994805342720868352/problems/994805409175420928 Given two sets of inte ...

  7. linux 转移mysql文件操作流程

    1.现将mysql停服 2.将文件拷贝到指定目录cp ./sales_trade_2.ibd /db/data/mysql/data_warehouse/sales_trade_2.ibd 3.检查新 ...

  8. hdu-题目:1058 Humble Numbes

    http://acm.hdu.edu.cn/showproblem.php?pid=1058 Problem Description A number whose only prime factors ...

  9. MVC SignalR Hub初学

    具体有关SignalR的说明查网上,我这里简单列举一个例子 1.新建MVC,添加SignalR引用(NuGet安装). 2.添加OWIN START类 public class Startup { p ...

  10. 【bzoj2741】[FOTILE模拟赛]L 可持久化Trie树+分块

    题目描述 FOTILE得到了一个长为N的序列A,为了拯救地球,他希望知道某些区间内的最大的连续XOR和. 即对于一个询问,你需要求出max(Ai xor Ai+1 xor Ai+2 ... xor A ...