搬圆桌问题

import java.util.Scanner;
import java.math.*;

/**
 * 搬圆桌问题
 * 先计算桌子起始点到要搬到的点的距离
 * 在牛客上提交运行的时候,应该使用Main为类名,不然会运行不通过
 *
*/

public class Deskmove {
    public static void main(String []args){
        Scanner input = new Scanner(System.in);
        double[] a = new double[5];
        for(int i = 0 ; i < 5 ; i++){
            a[i] = input.nextDouble() ;
        }
        move(a[0] , a[1] , a[2] , a[3] , a[4]);
    }
    static void move(double r , double x , double y ,double x1 , double y1){
        double lx = x1 - x ;
        double ly = y1 - y ;
        double ll = Math.pow(lx,2)+Math.pow(ly,2);
        double s = Math.sqrt(ll);
        System.out.println((int)Math.ceil(s/(2*r))); //ceil是上取整
    }
}
原文地址:https://www.cnblogs.com/sumbud/p/4869381.html