Codeforce 507B - Amr and Pins


Amr loves Geometry. One day he came up with a very interesting problem.

Amr has a circle of radiusrand 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 integersr,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.

Examples
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 by180degrees counter-clockwise (or clockwise, no matter).

 1 #include <iostream>
 2 #include <algorithm>
 3 #include <cstring>
 4 #include <cstdio>
 5 #include <vector>
 6 #include <cstdlib>
 7 #include <iomanip>
 8 #include <cmath>
 9 #include <ctime>
10 #include <map>
11 #include <set>
12 using namespace std;
13 #define lowbit(x) (x&(-x))
14 #define max(x,y) (x>y?x:y)
15 #define min(x,y) (x<y?x:y)
16 #define MAX 100000000000000000
17 #define MOD 1000000007
18 #define pi acos(-1.0)
19 #define ei exp(1)
20 #define PI 3.141592653589793238462
21 #define INF 0x3f3f3f3f3f
22 #define mem(a) (memset(a,0,sizeof(a)))
23 typedef long long ll;
24 ll gcd(ll a,ll b){
25     return b?gcd(b,a%b):a;
26 }
27 bool cmp(int x,int y)
28 {
29     return x>y;
30 }
31 const int N=10005;
32 const int mod=1e9+7;
33 int a[256];
34 int main()
35 {
36     std::ios::sync_with_stdio(false);
37     double r,x,y,x1,y1;
38     while(scanf("%lf%lf%lf%lf%lf",&r,&x,&y,&x1,&y1)!=EOF){
39         double dis=sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));
40         double d=2*r;
41         int cnt=dis/d;
42         if(cnt*d<dis)
43             cnt++;
44         printf("%d\n",cnt);
45     }
46     return 0;
47 }
优质内容筛选与推荐>>
1、SQL IF while 游标
2、MySQL初探索--小优化/常见错误问答
3、VUE前端
4、页面静态化
5、CLH Lock Queue 的实现


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号





    联系我们

    欢迎来到TinyMind。

    关于TinyMind的内容或商务合作、网站建议,举报不良信息等均可联系我们。

    TinyMind客服邮箱:support@tinymind.net.cn