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

could any one help me with this problem?
Posted by Zhou Yuan 10 Oct 2001 19:07
I always got wa, but i don't know why.
here's my program(very simple, perhaps i haven't understood
the task perfectly):
Const
    InFile    = '1070.in';

Var
    s1 , e1 ,
    s2 , e2    : real;

procedure readnum_sub(var n : real);
var
    c    : char;
begin
    n := 0;
    read(c);
    while not (c in ['0'..'9']) do read(c);
    while (not eoln) and (c in ['0'..'9']) do
      begin
          n := n * 10 + ord(c) - ord('0');
          read(c);
      end;
    if c in ['0'..'9'] then
      n := n * 10 + ord(c) - ord('0');
end;

procedure readnum(var n : real);
var
    a , b    : real;
begin
    readnum_sub(a);
    readnum_sub(b);
    n := a + b / 60;
end;

procedure init;
begin
    assign(INPUT , InFile); ReSet(INPUT);
      readnum(s1); readnum(e1);
      readln;
      readnum(s2); readnum(e2);
{    Close(INPUT);}
end;

procedure work;
var
    i    : integer;
    temp , t2    : real;
begin
    for i := 5 downto -5 do
      if i <> 0 then
      begin
          temp := e1 + i - s1;
          while temp < 0 do
            temp := temp + 24;
          if temp > 6 then
            continue;
          t2 := s2 + i + temp;
          if t2 >= 24 then
            t2 := t2 - 24;
          if abs(t2 - e2) <= 1 / 6 then
            begin
                writeln(abs(i));
                exit;
            end;
      end;
end;

Begin
    init;
    work;
End.