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