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

WA 1. Help me please
Posted by Pechenin Aleksey [Ivanovo SPU] 11 Oct 2008 01:57
{$APPTYPE CONSOLE}

var
 t1,t2,t3,t4: real;
 a1,a2,a3,a4: integer;

 k1,k2: integer;
 diff1, diff2: integer;

 i: integer;
begin
 Assign(input,'input.txt'); reset(input);
 Assign(output,'output.txt'); rewrite(output);

 readln(t1,t2);
 read(t3,t4);

 if t1 > t2 then t2 := t2 + 24;
 if t3 > t4 then t3 := t3 + 24;

 a1:=round(t1)*60;
 a2:=round(t2)*60;
 a3:=round(t3)*60;
 a4:=round(t4)*60;

 if  (t1-trunc(t1))>0.09 then  a1:=a1 + round((t1-trunc(t1))*100)
    else   a1:=a1  + round((t1-trunc(t1))*10);
  if  (t2-trunc(t2))>0.09 then  a2:=a2  + round((t1-trunc(t1))*100)
    else   a2:=a2  + round((t2-trunc(t2))*10);
  if  (t3-trunc(t3))>0.09 then  a3:=a3  + round((t3-trunc(t3))*100)
    else   a3:=a3  + round((t3-trunc(t3))*10);
  if  (t4-trunc(t4))>0.09 then  a4:=a4  + round((t4-trunc(t4))*100)
    else   a4:=a4  + round((t4-trunc(t4))*10);

 for i:=0 to 5  do
  begin
   diff1 := a1-i*60;
   diff2 := a4-i*60;
    k1:= abs(abs(diff1-a2));
    //writeln(k1 div 60,':',k1 mod 60, '   ',diff1,'-',a2,'  ', abs(diff1-a2));
    k2:= abs(abs(diff2-a3));
    //writeln(k1 div 60,':',k1 mod 60, '   ',diff2,'-',a3,'  ', abs(diff2-a3));

    //writeln(diff1 div 60,':', diff1 mod 60, '   ', t2:2:2);
    //writeln(t3:2:2,'   ',diff2 div 60,':', diff2 mod 60);


    if  abs(k1-k2)<=10 then writeln(i);
   end;
end.