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

Tel Me my Mistake please. I get WA#1
Posted by Mihran Hovsepyan {1 kurs of <RAU>} 15 Jan 2008 22:06
# include <iostream.h>
# include <stdio.h>
# include <cmath>
int main ()
{
    double A[2];
    double B[2];
    double C[2];
    double S,p,ab,ac,bc,hab,out[3];
    double L;
    cin>>A[0]>>A[1]>>B[0]>>B[1]>>C[0]>>C[1]>>L;
    ab=sqrt(pow((A[0]-B[0]),2)+pow((A[1]-B[1]),2));
    ac=sqrt(pow((A[0]-C[0]),2)+pow((A[1]-C[1]),2));
    bc=sqrt(pow((B[0]-C[0]),2)+pow((B[1]-C[1]),2));
    if (pow(ab,2)+pow(ac,2)>=pow(bc,2) && pow(ab,2)+pow(bc,2)>=pow(ac,2))
    {
        p=(ac+bc+ab)/2;
        S=sqrt(p*(p-ab)*(p-ac)*(p-bc));
        hab=(2*S)/ab;
        out[0]=hab-L;
    }
    else if (pow(ab,2)+pow(ac,2)<pow(bc,2) || pow(ab,2)+pow(bc,2)<pow(ac,2))
    {
        if (ac>bc)
            out[0]=bc-L;
        else
            out[0]=ac-L;
    }
    if (ac>bc)
        out[1]=ac-L;
    else
        out[1]=bc-L;
    for (int i=0;i<2;i++)
    {
        if(out[i]<0)
            out[i]=0.0;
    }
    printf("%.2f",out[0]);
    cout<<endl;
    printf("%.2f",out[1]);
    return 0;
}
Re: Tel Me my Mistake please. I get WA#1
Posted by Aram Shatakhtsyan 18 Jan 2008 17:07
Usually test #1 is the sample test in the problem
description.
Try to change your output format to

cout.setf(ios::fixed);
cout.precision(2);
cout<<out[0]<<endl<<out[1]<<endl;

Just add newline after output