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

How to print 0
Posted by Sid 25 Mar 2005 15:32
If length of rope is more then a distanse. Shall I print '0.00' or '0'. I get WA#9 and I know that second answer in 9th test is 0.
My source:
#include <iostream.h>
#include <stdio.h>
#include <math.h>

int main()
{
    double aa=-1,bb=-1,ax,ay,bx,by,cx,cy,l;
    cin>>ax>>ay>>bx>>by>>cx>>cy>>l;
    double a,b,c,p,s,h=0,m;
    c=sqrt(pow(bx-ax,2)+pow(by-ay,2));
    b=sqrt(pow(cx-ax,2)+pow(cy-ay,2));
    a=sqrt(pow(bx-cx,2)+pow(by-cy,2));
    if ((b>0)&&(c>0)) aa=(b*b+c*c-a*a)/(2*b*c);
    if ((a>0)&&(c>0))bb=(a*a+c*c-b*b)/(2*a*c);
    p=(a+b+c)/2;
    s=sqrt(p*(p-a)*(p-b)*(p-c));
    if (c>0) h=2*s/c;
    else h=b;
    if ((aa<0)||(bb<0))
    {if (b<a) m=b;
    else m=a;
    if (m>l) printf("%.2f\n",m-l);
    else printf("%.2f\n",0);
    }
    else if (h>l) printf("%.2f\n",h-l);
    else printf("%.2f\n",0);
    if (a<b) a=b;
    if (a>l) printf("%.2f\n",a-l);
    else printf("%.2f\n",0);
    return 0;

}
Re: How to print 0
Posted by Putilin Alexander 5 Apr 2005 12:17
You should write 0.00