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 1030. Titanic

Help. My program always got Wrong Answer!
Posted by crazy 23 Apr 2002 05:47
Maybe the input is wrong but i don't know how to do this
 help
thanks !

#include<iostream.h>
#include<math.h>
#include<stdio.h>
const double pi=3.1415926;
const double R=3437.5;

double x_ship,y_ship,z_ship;
double x_ice,y_ice,z_ice;
double dist(double x1,double y1,double z1,double x2,double y2,double
z2)
{
 double ans;
 ans=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2));
 return ans;
}

void main()
{
 double X1,X2,X3,Y1,Y2,Y3;
 double A1,A2,A3,B1,B2,B3;
 double ans,sita,d,r1,r2;
 int location_ship1,location_ship2,location_ice1,location_ice2;
 char ch[200];
 char c;

 //north=1;south=-1;east=1;west=-1;

 //input
 gets(ch);
 gets(ch);
 gets(ch);
 cin>>X1>>c>>X2>>c>>X3>>c>>ch;
 if(ch[0]=='N') location_ship1=1; else location_ship1=-1;
 cin>>ch>>Y1>>c>>Y2>>c>>Y3>>c>>ch;
 if(ch[0]=='E') location_ship2=1; else location_ship2=-1;
 gets(ch);
 cin>>A1>>c>>A2>>c>>A3>>c>>ch;
 if(ch[0]=='N') location_ice1=1; else location_ice1=-1;
 cin>>ch>>B1>>c>>B2>>c>>B3>>c>>ch;
 if(ch[0]=='E') location_ice2=1; else location_ice2=-1;
 gets(ch);


 z_ship=R*sin((X1+(X2+X3/60)/60)*pi/180);
 z_ship*=location_ship1;
 r1=R*cos((X1+(X2+X3/60)/60)*pi/180);
 z_ice=R*sin((A1+(A2+A3/60)/60)*pi/180);
 z_ice*=location_ice1;
 r2=R*cos((A1+(A2+A3/60)/60)*pi/180);

 y_ship=r1*cos((Y1+(Y2+Y3/60)/60)*pi/180);
 y_ice=r2*cos((B1+(B2+B3/60)/60)*pi/180);

 x_ship=r1*sin((Y1+(Y2+Y3/60)/60)*pi/180);
 x_ship*=location_ship2;
 x_ice=r2*sin((B1+(B2+B3/60)/60)*pi/180);
 x_ice*=location_ice2;

 d=dist(x_ship,y_ship,z_ship,x_ice,y_ice,z_ice);
 sita=acos((R*R*2-d*d)/(2*R*R));
 ans=R*sita;
 printf("The distance to the iceberg: %.2lf miles. \n",ans);
 if(ans<100) printf("DANGER!\n");
}
Re: Help. My program always got Wrong Answer!
Posted by Ivan Georgiev 24 Apr 2002 21:45
Your program prints DANGER if the answer is
99.999999;
you should print DANGER only if the number you have printed is
99.99 or less

Good luck.
Re: Help. My program always got Wrong Answer!
Posted by crazy 27 Apr 2002 19:21
thank you
 but i could not correct my program
and i still got the wrong answer
 whether you can tell me more

also i doubt whether my input code is ok?
 i am so lazy and i do in this way
Re: Help. My program always got Wrong Answer!
Posted by Ivan Georgiev 28 Apr 2002 00:50
Well, you could see how many symbols you have printed (i think printf
returns this), so if this number is ... (one more than usually), you
print 'DANGER!'

Good luck.