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 1070. Local Time

HEEEEEEEEEEEEEEEEEEELLLLLLLLLLLLLLPPPPPPP
Posted by Oleg 16 Jan 2003 16:05
var s:string;
    c1,c2,m1,m2,i:longint;
    t:array [1..2] of longint;
    t1,t2 : longint;
procedure svoy_del(var s:string);
begin
 while not(s[1] in ['0'..'9']) do delete(s,1,1);
end;

function svoy_val(var s:string):integer;
var c:integer;
begin
 c:=0;
 while s[1] in ['0'..'9'] do
 begin
  c:=c*10+ord(s[1])-ord('0');
  delete(s,1,1);
 end;
 svoy_val:=c;
end;

begin
 fillchar(t,sizeof(t),0);
 for i:=1 to 2 do
 begin
  readln(s); s:=s+' 9'; svoy_del(s);
  c1:=svoy_val(s);svoy_del(s);
  m1:=svoy_val(s);svoy_del(s);
  c2:=svoy_val(s);svoy_del(s);
  m2:=svoy_val(s);svoy_del(s);
  if m2<m1 then begin m2:=m2+60; c2:=c2-1;end;
  if c2<c1 then begin c2:=c2+24;end;
  c1:=c2-c1;
  m1:=m2-m1;
  t[i]:=m1+c1*60;
  if t[i]>12*60 then t[i]:=24*60-t[i];
 end;
 t1:=(round(abs(t[1]-t[2])/120));
 t1:=t1 mod 5;
 writeln(t1);
end.
I got AC
Posted by Oleg 17 Jan 2003 05:17
> var s:string;
>     c1,c2,m1,m2,i:longint;
>     t:array [1..2] of longint;
>     t1,t2 : longint;
> procedure svoy_del(var s:string);
> begin
>  while not(s[1] in ['0'..'9']) do delete(s,1,1);
> end;
>
> function svoy_val(var s:string):integer;
> var c:integer;
> begin
>  c:=0;
>  while s[1] in ['0'..'9'] do
>  begin
>   c:=c*10+ord(s[1])-ord('0');
>   delete(s,1,1);
>  end;
>  svoy_val:=c;
> end;
>
> begin
>  fillchar(t,sizeof(t),0);
>  for i:=1 to 2 do
>  begin
>   readln(s); s:=s+' 9'; svoy_del(s);
>   c1:=svoy_val(s);svoy_del(s);
>   m1:=svoy_val(s);svoy_del(s);
>   c2:=svoy_val(s);svoy_del(s);
>   m2:=svoy_val(s);svoy_del(s);
>   if m2<m1 then begin m2:=m2+60; c2:=c2-1;end;
>   if c2<c1 then begin c2:=c2+24;end;
>   c1:=c2-c1;
>   m1:=m2-m1;
>   t[i]:=m1+c1*60;
>   if t[i]>12*60 then t[i]:=24*60-t[i];
>  end;
>  t1:=(round(abs(t[1]-t[2])/120));
>  t1:=t1 mod 5;
>  writeln(t1);
> end.
>