CF 287(div 2) B Amr and Pins
解题思路:一开始自己想的是找出每一次旋转所得到的圆心轨迹,将想要旋转到的点代入该圆心轨迹的方程,如果相等,则跳出循环,如果不相等,则接着进行下一次旋转。后来看了题解,发现,它的旋转可以是任意角度的,所以旋转后的圆心应该在一个区域,而没有固定的圆心轨迹的方程。

如图所示,设c0为最初给出的圆,令圆c0绕O1点旋转,则对于绕O1点这一点的旋转来说,c1为其旋转后所得到的圆心轨迹,则可以看到,通过1次旋转后,距离最近为0,距离最远为线段OO2=2r,
对于第二次旋转,选取O2为圆心,作圆,再令圆c2绕O3旋转,得到圆心的轨迹为c3,离O点最近为OO2=2r,最远为OO4=4r
所以推出一般结论,令想要旋转到的点到起始的圆心的距离为d, 那么旋转次数为d/2r,这里的四舍五入用进1法(不能舍去,所以用ceil函数)
Amr loves Geometry. One day he came up with a very interesting problem.
Amr has a circle of radius r and center in point (x, y). He wants the circle center to be in new position (x', y').
In one step Amr can put a pin to the border of the circle in a certain point, then rotate the circle around that pin by any angle and finally remove the pin.
Help Amr to achieve his goal in minimum number of steps.
Input consists of 5 space-separated integers r, x, y, x' y' (1 ≤ r ≤ 105, - 105 ≤ x, y, x', y' ≤ 105), circle radius, coordinates of original center of the circle and coordinates of destination center of the circle respectively.
Output a single integer — minimum number of steps required to move the center of the circle to the destination point.
2 0 0 0 4
1
1 1 1 4 4
3
4 5 6 5 6
0
In the first sample test the optimal way is to put a pin at point (0, 2) and rotate the circle by 180 degrees counter-clockwise (or clockwise, no matter).

#include<stdio.h>
#include<math.h>
int main()
{
double i,r,x0,y0,x1,y1;
scanf("%lf %lf %lf %lf %lf",&r,&x0,&y0,&x1,&y1);
double dist=sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0));
printf("%.0lf\n",ceil(dist/(2*r)));
}
CF 287(div 2) B Amr and Pins的更多相关文章
- Codeforces Round #287 (Div. 2) B. Amr and Pins 水题
B. Amr and Pins time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- codeforcfes Codeforces Round #287 (Div. 2) B. Amr and Pins
B. Amr and Pins time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- Codeforces Round #287 (Div. 2) A. Amr and Music 水题
A. Amr and Music time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- 贪心 Codeforces Round #287 (Div. 2) A. Amr and Music
题目传送门 /* 贪心水题 */ #include <cstdio> #include <algorithm> #include <iostream> #inclu ...
- CF Amr and Pins (数学)
Amr and Pins time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- CF #376 (Div. 2) C. dfs
1.CF #376 (Div. 2) C. Socks dfs 2.题意:给袜子上色,使n天左右脚袜子都同样颜色. 3.总结:一开始用链表存图,一直TLE test 6 (1)如果需 ...
- CF #375 (Div. 2) D. bfs
1.CF #375 (Div. 2) D. Lakes in Berland 2.总结:麻烦的bfs,但其实很水.. 3.题意:n*m的陆地与水泽,水泽在边界表示连通海洋.最后要剩k个湖,总要填掉多 ...
- CF #374 (Div. 2) D. 贪心,优先队列或set
1.CF #374 (Div. 2) D. Maxim and Array 2.总结:按绝对值最小贪心下去即可 3.题意:对n个数进行+x或-x的k次操作,要使操作之后的n个数乘积最小. (1)优 ...
- CF #374 (Div. 2) C. Journey dp
1.CF #374 (Div. 2) C. Journey 2.总结:好题,这一道题,WA,MLE,TLE,RE,各种姿势都来了一遍.. 3.题意:有向无环图,找出第1个点到第n个点的一条路径 ...
随机推荐
- asp.net中Server.MapPath的使用
http://www.studyofnet.com/news/184.html 本文导读:Server.MapPath()的全名是System.Web.HttpContext.Current.Se ...
- 防范CSRF(三)
除了可以更改微软默认的cookie的名字外,还可以更改默认的加密方法.继承IAntiForgeryAdditionalDataProvider接口,实现里面的方法即可. 采用的加密方法有加盐和使用时间 ...
- Sphinx在windows下安装使用[支持中文全文检索]
原文地址:http://www.fuchaoqun.com/2008/11/sphinx-on-windows-xp/ 前 一阵子尝试使用了一下Sphinx,一个能够被各种语言(PHP/Python/ ...
- ZBrush国庆中秋大放价,优惠提前享!
没记错的话,上次的ZBrush活动应该是17年春节吧,悄么蔫地就把端午节等一系列节日忽略了,这让苦苦等待的小伙伴们情何以堪,这试用版用的也不得劲儿! 终于等到你,ZBrush官方消息称,17年中秋国庆 ...
- mybatis中if及concat函数的使用
- 配置HTTPS加密的快速参考指南
Nginx ssl_protocols TLSv1 TLSv1.1 TLSv1.2 阿帕奇 SSLProtocol All -SSLv2 -SSLv3 密码套房 选择密码套件可能很困难,它们的名称可能 ...
- Test zram at kernel 3.10 4.12
Use ltp to test zram 测试环境: #uname -r 3.10.0-327.ali2010.rc6.alios7.x86_64 没有指定zram algorithm(没有设置), ...
- Linux后台开发应该具备技能
一.linux和os: 1.命令:netstat tcpdump ipcs ipcrm 这四个命令的熟练掌握程度基本上能体现实际开发和调试程序的经验 2.cpu 内存 硬盘 等等与系统性能调试相关的命 ...
- Kz.layedit-layui.layedit富文本编辑器拓展
项目介绍 首先欢迎使用 Kz.layedit!本项目基于layui.layedit富文本编辑器,在其之上拓展而来. 新增功能 html源码模式.插入hr水平线.段落格式.字体颜色.字体背景色.批量上传 ...
- MySQL主从宕机的解决方法
测试系统:centos6.5系统 测试环境IP地址划分: master: 192.168.80.130 slave:192.168.80.143 slave:192.168.80.146 首先模拟(M ...