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. jar,war,ear区别及java基础杂七八

    jar,war,earqu区别 这三种文件都可以看作是java的压缩格式,其实质是实现了不同的封装: jar--封装类war--封装web站点ear--封装ejb.它们的关系具体为:jar:      ...

  2. Xcode 4 插件制作入门

    转自:http://www.onevcat.com/2013/02/xcode-plugin/ 2014.5.4更新 对于 Xcode 5,本文有些地方显得过时了.Xcode 5 现在已经全面转向了 ...

  3. HDU 4861 Couple doubi (数论 or 打表找规律)

    Couple doubi 题目链接: http://acm.hust.edu.cn/vjudge/contest/121334#problem/D Description DouBiXp has a ...

  4. POJ 2253 Frogger (dijkstra 最大边最小)

    Til the Cows Come Home 题目链接: http://acm.hust.edu.cn/vjudge/contest/66569#problem/A Description The i ...

  5. [iOS微博项目 - 1.2] - 导航栏搜索框

    A.导航栏搜索框 1.需求 在“发现”页面,在顶部导航栏NavigationBar上添加一个搜索框 左端带有“放大镜”图标 github: https://github.com/hellovoidwo ...

  6. C++中不常用关键字

    mutable关键字 关键字mutable是C++中一个不常用的关键字,他只能用于类的非静态和非常量数据成员.我们知道一个对象的状态由该对象的非静态数据成员决定,所以随着数据成员的改变,对像的状态也会 ...

  7. EcTouch二次开发

    一.EcTouch简介 1.1. 什么是ECTOUCH ECTouch是上海商创网络科技有限公司推出的一款开源免费移动商城网店系统,可以在手机上面卖商品的电子商务软件系统.能够帮助企业和个人快速构建手 ...

  8. Python3爬取中文网址

    本以为Python3的中文兼容性无比友好,结果还是会有一点问题的. 解决方案如下,就以爬取我自己的一个网页极简翻译为例 #coding:utf8 import urllib.request impor ...

  9. LINQ to XML 从逗号分隔值 (CSV) 文件生成 XML 文件

    参考:http://msdn.microsoft.com/zh-cn/library/bb387090.aspx 本示例演示如何使用 语言集成查询 (LINQ) 和 LINQ to XML 从逗号分隔 ...

  10. Squid代理服务器&&搭建透明代理网关服务器

    案例需求 ——公司选用RHEL5服务器作为网关,为了有效节省网络带宽.提高局域网访问Internet的速度,需要在网关服务器上搭建代理服务,并结合防火墙策略实现透明代理,以减少客户端的重复设置工作 需 ...