King's Sanctuary(简单几何)
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(简单几何)的更多相关文章
- cdoj 93 King's Sanctuary 傻逼几何题
King's Sanctuary Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/sho ...
- Python下opencv使用笔记(二)(简单几何图像绘制)
简单几何图像一般包含点.直线.矩阵.圆.椭圆.多边形等等.首先认识一下opencv对像素点的定义. 图像的一个像素点有1或者3个值.对灰度图像有一个灰度值,对彩色图像有3个值组成一个像素值.他们表现出 ...
- UESTC93 King's Sanctuary
King's Sanctuary Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) ...
- Codeforces 935 简单几何求圆心 DP快速幂求与逆元
A #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #def ...
- 简单几何(线段相交) POJ 2653 Pick-up sticks
题目传送门 题意:就是小时候玩的一种游戏,问有多少线段盖在最上面 分析:简单线段相交,队列维护当前最上的线段 /******************************************** ...
- osg for android (一) 简单几何物体的加载与显示
1. 首先需要一个OSG for android的环境. (1).NDK 现在Eclipse 对NDK已经相当友好了,已经不需要另外cygwin的参与,具体可以参考 Android NDK开发篇(一) ...
- HDU 6206 青岛网络赛1001 高精度 简单几何
给出的数据1e12规模,常规判点是否在圆范围内肯定要用到半径,求得过程中无法避免溢出,因此用JAVA自带的浮点大数运算,和个ZZ一样比赛中eclipse出现问题,而且太久没写JAVA语法都不清楚变量忘 ...
- CodeForces 703C Chris and Road (简单几何)
题意:有一个n边形的汽车向以速度v向x轴负方向移动,给出零时时其n个点的坐标.并且有一个人在(0,0)点,可以以最大速度u通过w宽的马路,到达(0,w)点.现在要求人不能碰到汽车,人可以自己调节速度. ...
- Jack Straws POJ - 1127 (简单几何计算 + 并查集)
In the game of Jack Straws, a number of plastic or wooden "straws" are dumped on the table ...
随机推荐
- winform界面之固定大小随dpi
场景: 已经更改成大小可随dpi改变,可是在用applyresoures()之后(添加更改语言功能),发现控件大小失真. 分析:applyresoures()是把该控件的属性改为程序设计的固定大小,不 ...
- “我爱淘”第二冲刺阶段Scrum站立会议5
完成任务: 完成了登录界面的实现,可以按照数据库中的用户名密码进行登录,. 计划任务: 在客户端实现分类功能,通过学院的分类查看书籍. 遇到问题: 再登录上了之后,并且保存密码,但是点击退出当前账号这 ...
- 缓存-System.Web.Caching.Cache
实现 Web 应用程序的缓存. 每个应用程序域创建一个此类的实例,只要应用程序域将保持活动状态,保持有效. 有关此类的实例的信息,请通过Cache的属性HttpContext对象或Cache属性的Pa ...
- PAT 甲级 1043 Is It a Binary Search Tree
https://pintia.cn/problem-sets/994805342720868352/problems/994805440976633856 A Binary Search Tree ( ...
- 太平洋网络ip地址查询接口使用,返回json格式,默认返回jsonp
http://whois.pconline.com.cn/ipJson.jsp?json=true
- Spring事务管理Transaction【转】
Spring提供了许多内置事务管理器实现(原文链接:https://www.cnblogs.com/qiqiweige/p/5000086.html): DataSourceTransactionMa ...
- 第99天:CSS3中透视perspective
CSS3中透视perspective 透视原理: 近大远小 . 浏览器透视:把近大远小的所有图像,透视在屏幕上. 理解浏览器的坐标系:浏览器平面为 Z=0的平面,坐标原点默认为图片的中心,可以通过更改 ...
- Appium与Robotium区别
Appium是基于UIAutomator框架实现的.Appium测试进程与目标应用进程是分开的,所以Appium不能直接访问目标应用的各种element属性进行copy&paste,而只能模拟 ...
- var和let使用上的对比
var和let比较 1. let没有预解析,不存在变量提升.在代码块中,只要let定义变量,在之前使用,都是报错.先定义完再使用. let a = 12; function fn(){ alert(a ...
- 移动端开发-viewport
1.viewport viewport 即设备 屏幕上显示网页的区域.因为移动设备屏幕比较小,为了能让移动设备能够显示更多内容,默认设置的viewport 并不是屏幕真是像素点的宽度,一般为980px ...