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. MySQL 新建用户和数据库

    MySQL 新建用户和数据库 修改MySql的密码为qwe123 /usr/local/bin/mysqladmin -u root -p password qwe123 mysql设置root远程访 ...

  2. CSS-05 html和body标签

    html和body标签 一直对这两个标签有迷惑,查了一些网上资料整理了一下. 1.html和body标签的背景 1.当给body一个背景色时候,背景图是充满整个窗口的,这里看上去是body标签下的背景 ...

  3. 对象名 XXX 无效。

    对象名 XXX 无效. 首先检查自己数据库连接字符串是否正确!!! 已经有过好几次这样的错误了,还是不长记性,特意记下

  4. Object.assign()遇到的问题分析

    概念 Object.assign() 方法可以把任意多个的源对象自身的可枚举属性拷贝给目标对象,然后返回目标对象.语法如下: Object.assign(target, ...sources) Obj ...

  5. 【LeetCode】回溯法 backtracking(共39题)

    [10]Regular Expression Matching [17]Letter Combinations of a Phone Number [22]Generate Parentheses ( ...

  6. day18 python模块 random time sys os模块

    day18 python   一.random模块     取随机整数 import random print(random.randint(1,2))                 #顾头顾尾 p ...

  7. SpringBoot集成H2database

    转载:https://blog.csdn.net/chenhao_c_h/article/details/80332260 h2database为我们提供了十分轻量,十分快捷方便的内嵌式数据库 H2是 ...

  8. java中的进制转换以及字符串类和数值类的相互转化

    import java.util.*; import java.io.*; import java.math.*; import java.math.*; public class Main { pu ...

  9. LOJ6437 PKUSC2018 PKUSC

    带劲的计算几何[这一定是我WC之前开的最后一道计几!!! 每个点画个圆然后看一下交点 然后判断是多边形内还是多边形外 这个就是取圆上中点然后射线法 eps我1e-8才过 不知道为啥有的人说只能开1e- ...

  10. input框金额输入验证

    金额输入要求:只能是数字且小数点后保留两位小数 html <input type="text" min="10" id="dc-moneyInp ...