any tricky there?

[pascal]

(* @JUDGE_ID: 13484EZ 535 Pascal "formula" *)

{D = R * ArcCos(cos(lat1)cos(lat2)[cos(long1)cos(long2) + sin(long1)sin(long2)] + sin(lat1)sin(lat2))

ArcCos(x) = ArcTan(sqrt(1 - sqr(x)) / x) }

const

maxcity = 1000;

R = 6378;

Pi = 3.141592653589793;

type

tcity = record

lat, long : real;

name : string[30];

end;

var

n : integer;

city : array[1..maxcity]of tcity;

function init : boolean;

var ch : char;

s : string;

begin

ch := #0;

s := '';

read(ch);

while (ch <> #26)and(ch <> '#')and(ch <> ' ')and(ch <> #9) do

begin s := s + ch; read(ch); end;

if s = '' then begin init := false; readln; exit; end;

inc(n);

city[n].name := s;

readln(city[n].lat, city[n].long);

city[n].lat := city[n].lat * pi / 180;

city[n].long := city[n].long * pi / 180;

init := true;

end;

function getid(name : string) : integer;

var i : integer;

begin

for i := 1 to n do

if city

*.name = name then*

begin getid := i; exit; end;

getid := 0;

end;

function sphericaldistance(i, j : integer) : real;

var q : real;

begin

q := cos(city

begin getid := i; exit; end;

getid := 0;

end;

function sphericaldistance(i, j : integer) : real;

var q : real;

begin

q := cos(city

*.lat) * cos(city[j].lat) * cos(city**.long - city[j].long) +*

sin(citysin(city

*.lat) * sin(city[j].lat);*

if q = 0 then q := Pi / 2 else

begin

q := sqrt (1 - sqr (q)) / q;

q := arctan(q);

if q < 0 then q := q + Pi;

end;

sphericaldistance := R * q;

end;

procedure main;

var s, name1, name2 : string;

i, c1, c2 : integer;

begin

readln(s);

i := pos(' ', s);

if i = 0 then i := pos(#9, s);

name1 := copy(s, 1, i - 1);

name2 := copy(s, i + 1, length(s) - i);

while (name1 <> '#') and (name2 <> '#') do

begin

writeln(name1, ' - ', name2);

c1 := getid(name1);

c2 := getid(name2);

if (c1 = 0) or (c2 = 0) then

writeln('Unknown')

else

writeln(sphericaldistance(c1, c2) : 0 : 0, ' km');

readln(s);

i := pos(' ', s);

if i = 0 then i := pos(#9, s);

name1 := copy(s, 1, i - 1);

name2 := copy(s, i + 1, length(s) - i);

end;

end;

begin

n := 0;

while init do;

main;

end.

[/pascal]if q = 0 then q := Pi / 2 else

begin

q := sqrt (1 - sqr (q)) / q;

q := arctan(q);

if q < 0 then q := q + Pi;

end;

sphericaldistance := R * q;

end;

procedure main;

var s, name1, name2 : string;

i, c1, c2 : integer;

begin

readln(s);

i := pos(' ', s);

if i = 0 then i := pos(#9, s);

name1 := copy(s, 1, i - 1);

name2 := copy(s, i + 1, length(s) - i);

while (name1 <> '#') and (name2 <> '#') do

begin

writeln(name1, ' - ', name2);

c1 := getid(name1);

c2 := getid(name2);

if (c1 = 0) or (c2 = 0) then

writeln('Unknown')

else

writeln(sphericaldistance(c1, c2) : 0 : 0, ' km');

readln(s);

i := pos(' ', s);

if i = 0 then i := pos(#9, s);

name1 := copy(s, 1, i - 1);

name2 := copy(s, i + 1, length(s) - i);

end;

end;

begin

n := 0;

while init do;

main;

end.

[/pascal]