Codeforces Round #287 (Div. 2)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 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.

Examples
input
Copy
2 0 0 0 4
output
Copy
1
input
Copy
1 1 1 4 4
output
Copy
3
input
Copy
4 5 6 5 6
output
Copy
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<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	double r,x,y,xx,yy;
	while(cin>>r>>x>>y>>xx>>yy)
	{
		double res=sqrt((xx-x)*(xx-x)+(yy-y)*(yy-y));
			res/=r*2;
			int ans=(int)res;
			if(ans!=res)
				ans++;
			cout<<ans<<endl;
	}
	return 0;
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章