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#2 !! Help me, please !
Posted by FireHeart 30 Jun 2007 18:00
Here is my code :

[Code Deleted]

I checked all test in all of topic and get correct answer.
(Sorry about my bad Eng)

Edited by author 04.07.2007 15:39
Re: WA#2 !! Help me, please !
Posted by FireHeart 4 Jul 2007 15:39
Thanks all , I have AC !
Re: WA#2 !! Help me, please !
Posted by Smilodon_am 3 Oct 2009 14:02
My bad program got WA2 on test

-2 6 2 6 0 0 0

AC program give right answer:

6.00
6.32
Re: WA#2 !! Help me, please !
Posted by AlexeyM-SSAU 4 Jan 2010 20:47
var X1,Y1,X2,Y2,X3,Y3,L:integer; cosa,cosb,A,B,C,p,H,L1,L2,O1,O2:real;
Begin
 Readln(X1,Y1,X2,Y2,X3,Y3,L);
  A:=SQRT(SQR(X3-X1)+SQR(Y3-Y1));
  B:=SQRT(SQR(X3-X2)+SQR(Y3-Y2));
  C:=SQRT(SQR(X2-X1)+SQR(Y2-Y1));
  p:=(A+B+C)/2;
 If (a=0) or (b=0) then
  Begin
   L1:=0;
   L2:=Abs(A-B);
  end
 else
  If C=0 then
   Begin
    L1:=A;
    L2:=A;
   end
  else
   Begin
    H:=2*SQRT(p*(p-A)*(p-B)*(p-C))/C;
    cosa:=(SQR(A)+SQR(c)-SQR(b))/(2*A*C);
    cosb:=(SQR(B)+SQR(C)-SQR(A))/(2*B*C);
    If (cosa<0) or (cosb<0) then
     If A>=B then L1:=B
     else L1:=A
    else L1:=H;
     If A>=B then
      L2:=A
     else L2:=B;
      end;
 If L>=L1 then O1:=0
 else
  O1:=abs(L1-L);
 If L>=L2 then O2:=0
 else
  O2:=abs(L2-L);
 Writeln(O1:0:2);
 Writeln(O2:0:2);
 Readln;
end.


working
Re: WA#2 !! Help me, please !
Posted by skyming 30 Oct 2011 10:50
no !!!
my text the same
6.00
6.32
got wa 2 text !!!!
my code:
#include<stdio.h>

#include<math.h>
typedef struct node
{
    double  x,y;
} point;
double max,min;double l;
double dis(point a,point b)
{
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
bool judge(point a,point b)
{
    double t=a.x*b.x+a.y*b.y;
    return t>=0;
}
void  fun(point a,point b,point c)
{
    double t=(a.y-c.y)*(b.x-c.x)-(b.y-c.y)*(a.x-c.x);
    t=fabs(t);
    // printf("%.3f\n",t);
    t/=sqrt((a.x-b.x)*(a.x-b.x) +(a.y-b.y)*(a.y-b.y));
    max=dis(a,c);
    if(dis(b,c)>max) max=dis(b,c);
    if(max>l) max-=l;
    else max=0;
    point pa,pb,px;px.x=0;px.y=0;
    if(dis(a,px)>dis(b,px))
     {
         pa.x=a.x-b.x;
         pa.y=a.y-b.y;
         pb.x=-b.x;
         pb.y=-b.y;
     }
    else
    {
         pa.x=b.x-a.x;
         pa.y=b.y-a.y;
         pb.x=-a.x;
         pb.y=-a.y;
    }
    if(judge(pa,pb))
    {
         min=t;
        // printf("dskafdk\n");
    }
    else
         min= dis(a,px)>dis(b,px) ? dis(a,px):dis(b,px);
   // printf("%.3f\n",min);
    if(min>l )  min-=l;
    else min=0;
}
int main()
{
    point a,b,c;

    scanf("%lf%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y,&l);
    fun(a,b,c);
    printf("%.2f\n%.2f",min,max);
    return 0;
}