Codeforces 271 Div 2 C. Captain Marmot
题目链接:http://codeforces.com/contest/474/problem/C
解题报告:给一个n,然后输入4*n个平面坐标系上的点,每四个点是一组,每个点有一个中心,这四个点可以分别围绕这个中心旋转,每次只能逆时针转90度,现在问你要使这四个点形成一个正方形最少要转的次数是多少。
枚举这四个点转的次数分别为0,1,2,3,只要这四种,因为再转的话就回到原来的状态循环了。然后对于每种情况分别判断是不是组成正方形就可以了,关键是求旋转后的坐标,和判断是不是正方形的问题。
假设这个点的坐标是(x,y),中心的点的坐标是(a,b),那么旋转90度之后这个点的坐标是(a - (y -b) , b+(x-a))
然后判断是不是正方形的方法:
任意取两个点求这两个点的距离,这样将得到六个距离,然后判断是不是有四个相等的距离另外两个是相等的,而且呈根号2倍的关系,同时还要判断距离都不能为0,满足这些条件就说明是正方形。
Codeforces 271 Div 2 C. Captain Marmot的更多相关文章
- codeforces#271 (Div. 2)预处理
B. Worms time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...
- Codeforces 271 Div 2 B. Worms
题目链接:http://codeforces.com/contest/474/problem/B 解题报告:给你n个堆,第i个堆有ai个物品,物品的编号从1开始,第一堆的编号从1到a1,第二堆编号从a ...
- Codeforces 271 Div 2 A Keyboard
题目链接:http://codeforces.com/contest/474/problem/A 解题报告:一个矩形的键盘,上面只有规定的字符,现在按的时候总是会向某个方向按偏,也就是输入一串字符后, ...
- C. Captain Marmot (Codeforces Round #271)
C. Captain Marmot time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- Codeforces Round #271 (Div. 2)题解【ABCDEF】
Codeforces Round #271 (Div. 2) A - Keyboard 题意 给你一个字符串,问你这个字符串在键盘的位置往左边挪一位,或者往右边挪一位字符,这个字符串是什么样子 题解 ...
- Codeforces Round #271 (Div. 2) 解题报告
题目地址:http://codeforces.com/contest/474 A题:Keyboard 模拟水题. 代码例如以下: #include <iostream> #include ...
- Codeforces Round #271 (Div. 2)
A. Keyboard 题意:一个人打字,可能会左偏一位,可能会右偏一位,给出一串字符,求它本来的串 和紫书的破损的键盘一样 #include<iostream> #include< ...
- 【CODEFORCES】 C. Captain Marmot
C. Captain Marmot time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- Codeforces 474 C. Captain Marmot
4*4*4*4暴力+点的旋转+推断正方型 C. Captain Marmot time limit per test 1 second memory limit per test 256 megaby ...
随机推荐
- ZOJ 1107FatMouse and Cheese(BFS)
题目链接 分析: 一个n * n的图,每个点是一个奶酪的体积,从0,0开始每次最多可以走k步,下一步体积必须大于上一步,求最大体积和 #include <iostream> #includ ...
- Yocto开发笔记之《驱动调试-华为3G模块》(QQ交流群:519230208)
QQ群:519230208,为避免广告骚扰,申请时请注明 “开发者” 字样 ======================================================== 参考:ht ...
- IEquatable 的Equals 代替 object 的Equals
struct Point2 : IEquatable<Point2> { public int X { get; set; } public int Y { get; set; } pub ...
- JQuery遍历方法$.each输出函数
each()方法能使DOM循环结构简洁,不容易出错.each()函数封装了十分强大的遍历功能,使用也很方便,它可以遍历一维数组.多维数组.DOM, JSON 等等在javaScript开发过程中使用$ ...
- docker中启动mysql报错
[root@5416ec39653b init.d]# /etc/init.d/mysqld start /etc/init.d/mysqld: line 23: /etc/sysconfig/net ...
- Hash Table in C
http://www.sparknotes.com/cs/searching/hashtables/section3.rhtml http://en.literateprograms.org/Spec ...
- ERROR 1130 (HY000) Host ‘hostname’ is not allowed to connect to this MySQL server
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'; FLUSH PRIVILEGES;
- Docker Dockerfile详解
http://blog.csdn.net/wsscy2004/article/details/25878223 如何使用 Dockerfile用来创建一个自定义的image,包含了用户指定的软件依赖等 ...
- JQuery.getJSON 从aspx页面返回JSON数据
public partial class WebForm2 : System.Web.UI.Page { protected void Page_Load(object sender, EventAr ...
- haproxy配置文件
haproxy配置文件 思路:读一行.写一行 global log 127.0.0.1 local2 daemon maxconn 256 log 127.0.0.1 local2 info de ...