B. Amr and Pins( Codeforces Round #287 (Div. 2))

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




#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main()
{
    double r,x1,y1,x2,y2;
    while(scanf("%lf%lf%lf%lf%lf",&r,&x1,&y1,&x2,&y2)!=EOF)
    {
        double aa = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
        int tt = 0;
        if(aa==0)
        {
            printf("0\n");
        }
        else if(aa<=2*r)
        {
            printf("1\n");
        }
        else
        {
            while(aa>2*r)
            {
                aa=aa-2*r;
                tt++;
            }
            printf("%d\n",tt+1);
        }
    }
    return 0;
}




部分数据:

 
 
1
Time: 15 ms,  memory: 0 KB
Verdict: OK
Input
2 0 0 0 4
Output
1
Answer
1
Checker comment
ok 1 number(s): "1"
 
 
2
Time: 0 ms,  memory: 0 KB
Verdict: OK
Input
1 1 1 4 4
Output
3
Answer
3
Checker comment
ok 1 number(s): "3"
 
 
3
Time: 31 ms,  memory: 0 KB
Verdict: OK
Input
4 5 6 5 6
Output
0
Answer
0
Checker comment
ok 1 number(s): "0"
 
 
4
Time: 15 ms,  memory: 0 KB
Verdict: OK
Input
10 20 0 40 0
Output
1
Answer
1
Checker comment
ok 1 number(s): "1"
 
 
5
Time: 0 ms,  memory: 0 KB
Verdict: OK
Input
9 20 0 40 0
Output
2
Answer
2
Checker comment
ok 1 number(s): "2"
 
 
6
Time: 15 ms,  memory: 0 KB
Verdict: OK
Input
5 -1 -6 -5 1
Output
1
Answer
1
Checker comment
ok 1 number(s): "1"
 
 
7
Time: 0 ms,  memory: 0 KB
Verdict: OK
Input
99125 26876 -21414 14176 17443
Output
1
Answer
1
Checker comment
ok 1 number(s): "1"
 
 
8
Time: 15 ms,  memory: 0 KB
Verdict: OK
Input
8066 7339 19155 -90534 -60666
Output
8
Answer
8
Checker comment
ok 1 number(s): "8"
 
 
9
Time: 0 ms,  memory: 0 KB
Verdict: OK
Input
100000 -100000 -100000 100000 100000
Output
2
Answer
2
Checker comment
ok 1 number(s): "2"
 
 
10
Time: 0 ms,  memory: 0 KB
Verdict: OK
Input
10 20 0 41 0
Output
2
Answer
2
Checker comment
ok 1 number(s): "2"
 
 
11
Time: 15 ms,  memory: 0 KB
Verdict: OK
Input
25 -64 -6 -56 64
Output
2
Answer
2
Checker comment
ok 1 number(s): "2"
 
 
12
Time: 0 ms,  memory: 0 KB
Verdict: OK
Input
125 455 450 439 721
Output
2
Answer
2
Checker comment
ok 1 number(s): "2"
 
 
13
Time: 0 ms,  memory: 0 KB
Verdict: OK
Input
5 6 3 7 2
Output
1
Answer
1
Checker comment
ok 1 number(s): "1"
 
 
14
Time: 15 ms,  memory: 0 KB
Verdict: OK
Input
24 130 14786 3147 2140
Output
271
Answer
271
Checker comment
ok 1 number(s): "271"
 
 
15
Time: 15 ms,  memory: 0 KB
Verdict: OK
Input
125 -363 176 93 330
Output
2
Answer
2
Checker comment
ok 1 number(s): "2"
 
 
16
Time: 15 ms,  memory: 0 KB
Verdict: OK
Input
1 14 30 30 14
Output
12
Answer
12
Checker comment
ok 1 number(s): "12"
 
 
17
Time: 0 ms,  memory: 0 KB
Verdict: OK
Input
25 96 13 7 2
Output
2
Answer
2
Checker comment
ok 1 number(s): "2"
 
 
18
Time: 0 ms,  memory: 0 KB
Verdict: OK
Input
4 100000 -100000 100000 -100000
Output
0
Answer
0
Checker comment
ok 1 number(s): "0"
 
 
19
Time: 0 ms,  memory: 0 KB
Verdict: OK
Input
1 3 4 2 5
Output
1
Answer
1
Checker comment
ok 1 number(s): "1"
 
 
20
Time: 0 ms,  memory: 0 KB
Verdict: OK
Input
1 -3 3 2 6
Output
3
Answer
3
Checker comment
ok 1 number(s): "3"
 
 
21
Time: 15 ms,  memory: 0 KB
Verdict: OK
Input
2 7 20 13 -5
Output
7
Answer
7
Checker comment
ok 1 number(s): "7"
 
 
22
Time: 15 ms,  memory: 0 KB
Verdict: OK
Input
1 1 1 1 4
Output
2
Answer
2
Checker comment
ok 1 number(s): "2"
 
 
23
Time: 0 ms,  memory: 0 KB
Verdict: OK
Input
249 -54242 -30537 -45023 -89682
Output
121
Answer
121
Checker comment
ok 1 number(s): "121"
 
 
24
Time: 0 ms,  memory: 0 KB
Verdict: OK
Input
4 100000 -100000 100000 -99999
Output
1
Answer
1
Checker comment
ok 1 number(s): "1"
 
 
25
Time: 15 ms,  memory: 0 KB
Verdict: OK
Input
97741 23818 78751 97583 26933
Output
1
Answer
1
Checker comment
ok 1 number(s): "1"
 
 
26
Time: 15 ms,  memory: 0 KB
Verdict: OK
Input
56767 -29030 51625 79823 -56297
Output
2
Answer
2
Checker comment
ok 1 number(s): "2"
 
 
27
Time: 15 ms,  memory: 0 KB
Verdict: OK
Input
98260 13729 74998 23701 9253
Output
1
Answer
1
Checker comment
ok 1 number(s): "1"
 
 
28
Time: 0 ms,  memory: 0 KB
Verdict: OK
Input
67377 -80131 -90254 -57320 14102
Output
1
Answer
1
Checker comment
ok 1 number(s): "1"
 
 
29
Time: 0 ms,  memory: 0 KB
Verdict: OK
Input
1 100000 100000 100000 -100000
Output
100000
Answer
100000
Checker comment
ok 1 number(s): "100000"
 
 
30
Time: 0 ms,  memory: 0 KB
Verdict: OK
Input
19312 19470 82059 58064 62231
Output
2
Answer
2
Checker comment
ok 1 number(s): "2"
 
 
31
Time: 15 ms,  memory: 0 KB
Verdict: OK
Input
67398 -68747 -79056 -34193 29400
Output
1
Answer
1
Checker comment
ok 1 number(s): "1"
 
 
32
Time: 0 ms,  memory: 0 KB
Verdict: OK
Input
91099 37184 -71137 75650 -3655
Output
1
Answer
1
Checker comment
ok 1 number(s): "1"
 
 
33
Time: 15 ms,  memory: 0 KB
Verdict: OK
Input
46456 -2621 -23623 -98302 -99305
Output
2
Answer
2
Checker comment
ok 1 number(s): "2"
 
 
34
Time: 0 ms,  memory: 0 KB
Verdict: OK
Input
100 100000 -100000 100000 -99999
Output
1
Answer
1
Checker comment
ok 1 number(s): "1"
 
 
35
Time: 0 ms,  memory: 0 KB
Verdict: OK
Input
1 100000 -100000 100000 -100000
Output
0
Answer
0
Checker comment
ok 1 number(s): "0"
 
 
36
Time: 15 ms,  memory: 0 KB
Verdict: OK
Input
8 0 0 0 32
Output
2
Answer
2
Checker comment
ok 1 number(s): "2"
 
 
37
Time: 15 ms,  memory: 0 KB
Verdict: OK
Input
100000 100000 1 -100000 0
Output
2
Answer
2
Checker comment
ok 1 number(s): "2"


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

叶孤心丶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值