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;
}