B. Amr and Pins
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 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

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).

画个图可发现到以圆的边界为转动中心,可以到达的新的圆的中心集也是一个圆。

且原点x , y 到点x' , y'的关系.

是sqrt ((x-x')^2 + (y-y')^2) ..与 2*R的距离有关的。

#include<bits/stdc++.h>
using namespace std;
int main()
{
double r , x0 , y0 , x1 , y1 ;
while( cin >> r >> x0 >> y0 >> x1 >> y1 ) {
r *= 2.0 ;
double a = fabs(x1-x0) / r , b = fabs(y1-y0) / r ;
double c = sqrt( a*a + b*b );
printf("%.0lf\n",ceil(c));
}
}

Codefores 507B Amr and Pins的更多相关文章

  1. Codeforce 507B - Amr and Pins

    Amr loves Geometry. One day he came up with a very interesting problem. Amr has a circle of radius r ...

  2. CodeForces - 507B - Amr and Pins(计算几何)

    Amr loves Geometry. One day he came up with a very interesting problem. Amr has a circle of radius r ...

  3. codeforces 507B. Amr and Pins 解题报告

    题目链接:http://codeforces.com/problemset/problem/507/B 题目意思:给出圆的半径,以及圆心坐标和最终圆心要到达的坐标位置.问最少步数是多少.移动见下图.( ...

  4. CF Amr and Pins (数学)

    Amr and Pins time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  5. 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 ...

  6. 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 ...

  7. CF 287(div 2) B Amr and Pins

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

  8. CodeForces Round #287 Div.2

    A. Amr and Music (贪心) 水题,没能秒切,略尴尬. #include <cstdio> #include <algorithm> using namespac ...

  9. ffmpeg常用转换命令,支持WAV转AMR

    音频转换: 1.转换amr到mp3: ffmpeg -i shenhuxi.amr amr2mp3.mp3 2.转换amr到wav: ffmpeg -acodec libamr_nb -i shenh ...

随机推荐

  1. 使用join和CountDownLatch来等待线程结束

    1.join方法的实现 join只能在start()之后调用, join 某个线程A,会使当前线程B进入等待,直到线程A结束生命周期(isAlive()==false) ,或者达到给定的时间. 在此期 ...

  2. [置顶]unity常用开发套件

    维京人骨骼动画制作(Unity 2D Animation资源包使用指南) 维京人骨骼动画制作2(Unity 2D IK资源包使用指南) -------------------------------- ...

  3. 164-基于TI DSP TMS320C6455和Altera FPGA EP2S130的Full CameraLink PDS150接口板卡

    一.板卡概述 本板卡由我公司自主研发,板卡采用DSP+FPGA的结构,DSP使用TMS320C6455芯片,FPGA采用ALTERA的高端FPGA芯片Stratix II EP2S系列EP2S130, ...

  4. 前端学习(三十四)对象&模块化(笔记)

    人,工人 //类的定义    function Person(name,age){ //构造函数        //工厂模式        //1.原料        //var obj = new ...

  5. SAP固定资产(FI-AA),一网打尽(转)

    在固定资产模块的边缘,游荡了四五年的时间了,细细数来,固定资产这个熟悉又抽象的东西(熟悉是由于天天接触常常听说,抽象是具体到系统实现上有些复杂并且常遇到问题),好像也没有多少东西. 1) SAP固定资 ...

  6. Go 使用 append 向切片增加元素

    1.// 创建一个整型切片 // 其长度和容量都是 5 个元素 slice := []int{10, 20, 30, 40, 50} // 创建一个新切片 // 其长度为 2 个元素,容量为 4 个元 ...

  7. Hadoop中的排序和连接

    MapReduce的全排序 主要是为了保证分区排序,即第一个分区的最后一个Key值小于第二个分区的第一个Key值 与普通的排序仅仅多一个自定义分区类MyPartitioner见自己所写的实验 (设置一 ...

  8. Unparseable date: "Mon Aug 15 11:24:39 CST 2016",时间格式转换异常

    String datestr= "Mon Aug 15 11:24:39 CST 2016";//Date的默认格式显示 Date date=new SimpleDateForma ...

  9. leetcode-15双周赛-1288-删除被覆盖区间

    题目描述: 方法一:排序O(Nlogn) class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -& ...

  10. jmeter+ant+jenkins搭建接口自动化测试环境

    jmeter+ant+jenkins搭建接口自动化测试环境(基于win) 1.jmeter jmeter依赖java运行环境,所以需要提前下载jdk并配置好环境变量 官网下载(http://jmete ...