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 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 a single integer — minimum number of steps required to move the center of the circle to the destination point.
2 0 0 0 4
1
1 1 1 4 4
3
4 5 6 5 6
0
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; }
部分数据:
2 0 0 0 4
1
1
ok 1 number(s): "1"
1 1 1 4 4
3
3
ok 1 number(s): "3"
4 5 6 5 6
0
0
ok 1 number(s): "0"
10 20 0 40 0
1
1
ok 1 number(s): "1"
9 20 0 40 0
2
2
ok 1 number(s): "2"
5 -1 -6 -5 1
1
1
ok 1 number(s): "1"
99125 26876 -21414 14176 17443
1
1
ok 1 number(s): "1"
8066 7339 19155 -90534 -60666
8
8
ok 1 number(s): "8"
100000 -100000 -100000 100000 100000
2
2
ok 1 number(s): "2"
10 20 0 41 0
2
2
ok 1 number(s): "2"
25 -64 -6 -56 64
2
2
ok 1 number(s): "2"
125 455 450 439 721
2
2
ok 1 number(s): "2"
5 6 3 7 2
1
1
ok 1 number(s): "1"
24 130 14786 3147 2140
271
271
ok 1 number(s): "271"
125 -363 176 93 330
2
2
ok 1 number(s): "2"
1 14 30 30 14
12
12
ok 1 number(s): "12"
25 96 13 7 2
2
2
ok 1 number(s): "2"
4 100000 -100000 100000 -100000
0
0
ok 1 number(s): "0"
1 3 4 2 5
1
1
ok 1 number(s): "1"
1 -3 3 2 6
3
3
ok 1 number(s): "3"
2 7 20 13 -5
7
7
ok 1 number(s): "7"
1 1 1 1 4
2
2
ok 1 number(s): "2"
249 -54242 -30537 -45023 -89682
121
121
ok 1 number(s): "121"
4 100000 -100000 100000 -99999
1
1
ok 1 number(s): "1"
97741 23818 78751 97583 26933
1
1
ok 1 number(s): "1"
56767 -29030 51625 79823 -56297
2
2
ok 1 number(s): "2"
98260 13729 74998 23701 9253
1
1
ok 1 number(s): "1"
67377 -80131 -90254 -57320 14102
1
1
ok 1 number(s): "1"
1 100000 100000 100000 -100000
100000
100000
ok 1 number(s): "100000"
19312 19470 82059 58064 62231
2
2
ok 1 number(s): "2"
67398 -68747 -79056 -34193 29400
1
1
ok 1 number(s): "1"
91099 37184 -71137 75650 -3655
1
1
ok 1 number(s): "1"
46456 -2621 -23623 -98302 -99305
2
2
ok 1 number(s): "2"
100 100000 -100000 100000 -99999
1
1
ok 1 number(s): "1"
1 100000 -100000 100000 -100000
0
0
ok 1 number(s): "0"
8 0 0 0 32
2
2
ok 1 number(s): "2"
100000 100000 1 -100000 0
2
2
ok 1 number(s): "2"