ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1348. Goat in the Garden 2

WA 5 pls. help me . thanks beforehand
Posted by Paata Julakidze[GTU] 6 May 2014 16:55
import java.util.Scanner;


public class Problem_1348 {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int ax,ay,bx,by,cx,cy,l;
        double ac,bc,ab,x,min,A,B,C,h;
        x=h=0;
        ax=in.nextInt();
        ay=in.nextInt();
        bx=in.nextInt();
        by=in.nextInt();
        cx=in.nextInt();
        cy=in.nextInt();
        l=in.nextInt();

        ab= Math.sqrt( (bx-ax)*(bx-ax)+(by-ay)*(by-ay) );
        ac =Math.sqrt( (cx-ax)*(cx-ax)+ (cy-ay)*(cy-ay) );
        bc= Math.sqrt( (cx-bx)*(cx-bx) + (cy-by)*(cy-by) );
        A=ac; B=bc; C=ab;

        x=(A*A-B*B+C*C)/(2*C);
       h= Math.sqrt((A*A-x*x));
         min=h;


          if(A>B){
            if(min-l<0)System.out.printf("%.2f",0.00); else System.out.printf("%.2f",min-l);
            System.out.println();
            if(A-l<0)System.out.printf("%.2f",0.00);else System.out.printf("%.2f",A-l);
        }else{
            if(min-l<0)System.out.printf("%.2f",0.00); else System.out.printf("%.2f",min-l);
            System.out.println();
            if(A-l<0)System.out.printf("%.2f",0.00);else System.out.printf("%.2f",B-l);
        }

    }
 }

Edited by author 06.05.2014 16:57
Re: WA 5 pls. help me . thanks beforehand
Posted by sergovoy 10 Jan 2017 22:51
Если основание высоты не попадает в отрезок AB, то такого расстояния не хватит