ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1030. Titanic

sample
Posted by remdy21 4 Aug 2009 16:22
why my answer is 52.14?
Re: sample
Posted by remdy21 4 Aug 2009 17:11
my code is:
program titanic;
uses math;
const r=3437.5;
var s:char;
a,b,c,x,y,z,d,e,u,v,w:extended;
begin
assign(input,'titanic.in');
assign(output,'titanic.out');
reset(input);
rewrite(output);
while s<>'^' do
begin
a:=a*10+ord(s)-48;
end;
while s<>chr(39) do
begin
z:=z*10+ord(s)-48;
end;
a:=a+z/60;
z:=0;
while s<>'"' do
begin
z:=z*10+ord(s)-48;
end;
a:=a+z/3600;
if s='S' then
a:=-a;
while s<>'^' do
begin
b:=b*10+ord(s)-48;
end;
z:=0;
while s<>chr(39) do
begin
z:=z*10+ord(s)-48;
end;
b:=b+z/60;
z:=0;
while s<>'"' do
begin
z:=z*10+ord(s)-48;
end;
b:=b+z/3600;
if s='W' then
b:=-b;
while s<>'^' do
begin
x:=x*10+ord(s)-48;
end;
z:=0;
while s<>chr(39) do
begin
z:=z*10+ord(s)-48;
end;
x:=x+z/60;
z:=0;
while s<>'"' do
begin
z:=z*10+ord(s)-48;
end;
x:=x+z/3600;
if s='S' then
x:=-x;
while s<>'^' do
begin
y:=y*10+ord(s)-48;
end;
z:=0;
while s<>chr(39) do
begin
z:=z*10+ord(s)-48;
end;
y:=y+z/60;
z:=0;
while s<>'"' do
begin
z:=z*10+ord(s)-48;
end;
y:=y+z/3600;
if s='W' then
y:=-y;
c:=sin(a);
z:=cos(a);
d:=z*cos(b);
e:=z*sin(b);
u:=sin(x);
z:=cos(x);
v:=z*cos(y);
w:=z*sin(y);
z:=c*u+d*v+e*w;
z:=r*pi*arccos(z)/180;
writeln('The distance to the iceberg: ',z:0:8,' miles.');
if z<99.995 then
writeln('DANGER!');
end.