287# div2 B Amr and Pins

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

给了两张图大概内容就是例子一通过按(0,2)转动180度使在(0,0)的中点到要求位置(0,4); 

题目大意,给你圆的半径r和初始末的位置,你可以围绕圆上的一点进行转动,问最小多少次,题目很好理解,要求就是问你始末位置的距离是直径的多少倍。水题,不过一开始思路有问题wa了几次,注意点在(-1e5,-1e5)到(1e5,1e5)之间所以double的精度不够,只能做乘法。

#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main()
{
    __int64 x1,x2,y1,y2,r,i,x,y;
    while(cin>>r>>x1>>y1>>x2>>y2)
    {
        if(x1==x2&&y1==y2){
            cout<<0<<endl;
            continue;
        }
        x=(x1-x2)*(x1-x2);
        y=(y1-y2)*(y1-y2);
        i=1;
        while((double)(x+y)/(i*i*4*r*r)>1)
            i++;
        cout<<i<<endl;
    }
    return 0;
}

 

posted @ 2015-01-24 18:23  乱齐八糟  阅读(203)  评论(0编辑  收藏  举报