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. 石家庄铁道大学网站首页UI分析

    今天的软件工程王老师讲了UI的设计,以前狭隘的认为只有移动设备上的界面叫UI,百度一下才发现UI其实有这么多含义:UI即User Interface的简称.泛指用户的操作界面,UI设计主要指界面的样式 ...

  2. Alpha 冲刺6

    队名:日不落战队 安琪(队长) 今天完成的任务 回收站前端界面. 明天的计划 查看个人信息界面. 还剩下的任务 信息修改前端界面. 设置界面. 遇到的困难 模拟机莫名其妙就崩了,调试了很久,后在队友的 ...

  3. OSG学习:使用OSG中预定义的几何体

    常用的内嵌几何体包括: osg::Box //正方体 osg::Capsule //太空舱 osg::Cone //椎体 osg::Cylinder //柱体 osg::HeightField //高 ...

  4. Android ContentProvider基本用法

    转自:https://www.jianshu.com/p/601086916c8f 一.基本概念 ContentProvider是Android系统中提供的专门用户不同应用间进行数据共享的组件,提供了 ...

  5. linux的一些机制Signal, Fork,

    signal(SIGCHLD, SignalHandler); 注册软中断,对应的api close(socket); ret=fork(): 父进程,返回子进程的pid. 子进程返回0, 出错返回& ...

  6. 基于opencv的小波变换代码和图像结果

    #include "stdafx.h" #include "WaveTransform.h" #include <math.h> #include ...

  7. 第161天:CSS3实现兼容性的渐变背景(gradient)效果

    CSS实现兼容性的渐变背景(gradient)效果 一.有点俗态的开场白 在对CSS3支持日趋完善的今天,实现兼容性的渐变背景效果已经完全成为可能,本文就将展示如何实现兼容性的渐变背景效果.在众多的浏 ...

  8. bzoj3517 翻硬币

    题意 有一个n行n列的棋盘,每个格子上都有一个硬币,且n为偶数.每个硬币要么是正面朝上,要么是反面朝上.每次操作你可以选定一个格子(x,y),然后将第x行和第y列的所有硬币都翻面.求将所有硬币都变成同 ...

  9. 【bzoj5174】[Jsoi2013]哈利波特与死亡圣器 二分+树形dp

    题目描述 给你一棵以1为根的有根树,初始除了1号点为黑色外其余点均为白色.Bob初始在1号点.每次Alice将其中至多k个点染黑,然后Bob移动到任意一个相邻节点,重复这个过程.求最小的k,使得无论B ...

  10. VS中碰到的问题

    1.调试的时候,语句已经注释掉了,但是在执行的时候还是运行了(或者某些变量值改变后,程序依然用的之前数据). 右键解决方案-->清理,然后重新生成.