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

把两个圆抽象成两个点,两个点的坐标是圆心,那么最短的距离就是这两点的距离,而每次能移动的最大距离是2R,所以每次先移动那么多,直到最后接近的时候,又从某个不同的点开始旋转。说实话我无法证明最后这个旋转一定能到达,但是凭着直觉就敲上去了,结果1A,运气吧。

 #include <bits/stdc++.h>
using namespace std; int main(void)
{
double s,r;
double x_1,y_1,x_2,y_2;
int ans; scanf("%lf",&r);
scanf("%lf%lf%lf%lf",&x_1,&y_1,&x_2,&y_2);
s = sqrt(pow(x_1 - x_2,) + pow(y_1 - y_2,)); ans = s / ( * r);
if(ans * r * < s)
ans += ;
printf("%d\n",ans); return ;
}

CF Amr and Pins (数学)的更多相关文章

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

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

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

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

  4. Codefores 507B Amr and Pins

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

  5. CF Amr and Music (贪心)

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

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

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

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

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

  9. (简单) CF 44D Hyperdrive,数学。

    In a far away galaxy there are n inhabited planets, numbered with numbers from 1 to n. They are loca ...

随机推荐

  1. JavaIO(01)File类详解

    File类 file类中的主要方法和变量   常量: 表示路径的分割符:(windows) 作用:根据java可移植性的特点,编写路径一定要符合本地操作系统要求的分割符: public static ...

  2. Hibernate3注解

    1.@Entity(name="EntityName") 必须,name为可选,对应数据库中一的个表 2.@Table(name="",catalog=&quo ...

  3. C#引用传递

    学过C#的人都知道,通过值或通过引用,值类型和引用类型都可以作为方法参数传递.在C#中,不管是值类型或者是引用类型,所有方法参数在默认情况下是通过值传递的. 1)通过值传递值类型 在通过值传递作为方法 ...

  4. SQl函数的写法

    USE [ChangHong_612]GO/****** Object: UserDefinedFunction [dbo].[FN_GetProdQty] Script Date: 10/08/20 ...

  5. C++中标准容器Vector,元素操作.insert()小结

    insert() 函数有以下三种用法: iterator insert( iterator loc, const TYPE &val );  //在指定位置loc前插入值为val的元素,返回指 ...

  6. 汇编语言(学习笔记-----[bx]和loop)

    1.[bx]是什么??     和[0]有些类似,[0]表示内存单元,它的偏移地址是0      [bx]同样也表示一个内存单元,它的偏移地址在bx中,mov ax,[bx]  (字)   mov  ...

  7. 测试URL有效性

    方法一: #禁用滚动条 $ProgressPreference='silentlycontinue' Invoke-WebRequest "www.163.com" -UseBas ...

  8. Galera 10.0.20 on CentOS 6.6

    Galera 10.0.20 on CentOS 6.6 0.使用场景 数据库软件:mariadb-galera-10.0.20-linux-x86_64.tar.gz 集群管理:galera-3-2 ...

  9. Codeforces Round #328 (Div. 2) D. Super M 虚树直径

    D. Super M Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/592/problem/D ...

  10. 401 Palindromes(回文词)

      Palindromes  A regular palindrome is a string of numbers or letters that is the same forward as ba ...