现在有一张半径为r的圆桌,其中心位于(x,y),现在他想把圆桌的中心移到(x1,y1)。每次移动一步,都必须在圆桌边缘固定一个点然后将圆桌绕这个点旋转。问最少需要移动几步。
输入描述:
一行五个整数r,x,y,x1,y1(1≤r≤100000,-100000≤x,y,x1,y1≤100000)
输出描述:
输出一个整数,表示答案
输入例子:
2 0 0 0 4
输出例子:
1
import java.util.Scanner;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner s = new Scanner(System.in);
// System.out.println(50466*50466);
while(s.hasNext()){
String rstr = s.next();
int r = Integer.parseInt(rstr);
String xstr = s.next();
int x = Integer.parseInt(xstr);
String ystr = s.next();
int y = Integer.parseInt(ystr);
String x1str = s.next();
int x1 = Integer.parseInt(x1str);
String y1str = s.next();
int y1 = Integer.parseInt(y1str);
Table t = new Table();
System.out.println(t.move(r, x, y, x1, y1));
}
}
}
class Table{
public int move(int r, int x, int y, int x1, int y1){//返回值:需要移动桌子的次数
// (x,y)->(0,0) (x1,y1)->(x2,y2)
// double r0 = (double)r;
double x2 = x1-x;
double y2 = y1-y;
double d = Math.sqrt(x2*x2+y2*y2);
int times = 0;
double len = 0;
if(d==r){
return times;
}
while(len+2*r<d){//int型会超出范围
times++;
len=len+2*r;
}
times++;
return times;
}
}