java自己编译可以通过 但是洛谷样例全部是紫色RE无法通过

P5735 【深基7.例1】距离函数

magicmelonG @ 2023-01-25 09:37:00


import java.util.Scanner;
 class point {
    private double x,y;
    public point(double x,double y) {
        this.x=x;
        this.y=y;
    }
    public double getx() {
        return x;
    }
    public double gety() {
        return y;
    }

}

public class Main {
    public static void main(String []args) {
        point[] ppp= new point[4];

        for(int i=0;i<3;i++) {
            Scanner sc=new Scanner(System.in);
            int x1=sc.nextInt();
            int x2=sc.nextInt();
            ppp[i]=new point(x1,x2);
            //System.out.print(ppp[i].getx());
            //System.out.print(ppp[1].gety());

        }
        double distance,d1,d2,d3;
        d1=Math.sqrt((ppp[0].getx()-ppp[2].getx())*(ppp[0].getx()-ppp[2].getx())+(ppp[0].gety()-ppp[2].gety())*(ppp[0].gety()-ppp[2].gety()));
        d2=Math.sqrt((ppp[1].getx()-ppp[0].getx())*(ppp[1].getx()-ppp[0].getx())+(ppp[1].gety()-ppp[0].gety())*(ppp[1].gety()-ppp[0].gety()));
        d3=Math.sqrt((ppp[1].getx()-ppp[2].getx())*(ppp[1].getx()-ppp[2].getx())+(ppp[1].gety()-ppp[2].gety())*(ppp[1].gety()-ppp[2].gety()));
        distance=d1+d2+d3;
        System.out.print(String.format("%.2f", distance));

    }

}

|