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

如图所示,设c0为最初给出的圆,令圆c0绕O1点旋转,则对于绕O1点这一点的旋转来说,c1为其旋转后所得到的圆心轨迹,则可以看到,通过1次旋转后,距离最近为0,距离最远为线段OO2=2r,

对于第二次旋转,选取O2为圆心,作圆,再令圆c2绕O3旋转,得到圆心的轨迹为c3,离O点最近为OO2=2r,最远为OO4=4r

所以推出一般结论,令想要旋转到的点到起始的圆心的距离为d, 那么旋转次数为d/2r,这里的四舍五入用进1法(不能舍去,所以用ceil函数)

B. Amr and Pins

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

Input consists of 5 space-separated integers rxyxy' (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

Output a single integer — minimum number of steps required to move the center of the circle to the destination point.

Sample test(s)
input
2 0 0 0 4
output
1
input
1 1 1 4 4
output
3
input
4 5 6 5 6
output
0
Note

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)));
}

  

最新文章

  1. Xtrabackup原理及使用innobackupex进行MySQL数据库备份恢复
  2. api接口类型
  3. Nginx php-fpm php mysql
  4. python文件和元组
  5. 使用WebView视图显示网页-----迷你浏览器
  6. Spring事务传递性探讨
  7. 自然语言.例如:求n!。
  8. minSdkVersion与targetSdkVersion
  9. [iOS、Unity、Android] 浅谈闭包的使用方法
  10. TCP/IP 协议栈 -- 编写UDP客户端注意细节
  11. 针对Chrome谷歌等浏览器不再支持showModalDialog的解决方案
  12. 学习笔记:Zookeeper选举机制
  13. git常用笔记整理
  14. 换工作之后需要兼容ie8的我
  15. 2554 ACM 杭电 数学
  16. Android 自定义ImageView支持缩放,拖拽,方便复用
  17. 6-1 平衡的括号 uva673
  18. hadoop2.2.0 centos 编译安装详解
  19. Android Studio OkHttpClient使用
  20. e559. 创建窗口

热门文章

  1. 大话主席(superslide和 touchslide)插件的使用
  2. firstChild与firstElementChild
  3. 移动web中的流式布局和viewport知识介绍
  4. Unity 导入的模型检测不到碰撞
  5. WoSign全球可信网站安全认证签章安装指南
  6. BZOJ 5020 [THUWC2017]Drown in the math ocean (LCT+求导)
  7. [CodeForces]529B Group Photo 2
  8. nginx 过滤zip 类型的文件
  9. python的基础及练习
  10. s5k4ba摄像头驱动分析