Advertisement
savrasov

clocks

Nov 30th, 2016
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.48 KB | None | 0 0
  1. program zC;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6.   SysUtils;
  7.  
  8. type
  9.   time = record
  10.     h, s, m: string;
  11.   end;
  12.  
  13. var
  14.   f, x, y, z, a, b, h1, m1, s1, h2, m2, s2, lh, lm, ls, tt: integer;
  15.   c: char;
  16.   n, k: time;
  17.  
  18. function obr(s: string; len: integer): string;
  19. begin
  20.   while (length(s) < len) do s := '0' + s;
  21.   obr := s;
  22. end;
  23.  
  24. function timez(h, m, s: integer): time;
  25. begin
  26.   timez.h := obr(inttostr(h), lh);
  27.   timez.m := obr(inttostr(m), lm);
  28.   timez.s := obr(inttostr(s), ls);
  29. end;
  30.  
  31. function check(a: time): boolean;
  32. begin
  33.   check := ((pos(c, a.h) <> 0) or (pos(c, a.m) <> 0) or (pos(c, a.s) <> 0));
  34. end;
  35.  
  36. function incs(f: time): time;
  37. var
  38.   h, m, s, t: integer;
  39. begin
  40.   h := strtoint(f.h);
  41.   m := strtoint(f.m);
  42.   s := strtoint(f.s);
  43.   t := h * a * b + m * b + s;
  44.   inc(t);
  45.   if (t = tt) then incs := timez(0, 0, 0)
  46.   else
  47.   begin
  48.     h := t div (a * b);
  49.     m := (t - h * a * b)div b;
  50.     s := (t - h * a * b - m * b);
  51.     incs := timez(h, m, s);
  52.   end;
  53. end;
  54.  
  55. function ll(k: integer): integer;
  56. begin
  57.   if (k div 10 = 0) then ll := 1
  58.   else ll := 2;
  59. end;
  60.  
  61. begin
  62.   readln(a, b);
  63.   readln(x, y, z);
  64.   lh := ll(x); lm := ll(y); ls := ll(z);
  65.   tt := x * a * b + y * b + z;
  66.   readln(h1, m1, s1);
  67.   readln(h2, m2, s2);
  68.   readln(c);
  69.   n := timez(h1, m1, s1);
  70.   k := timez(h2, m2, s2);
  71.   f := 0;
  72.   while (true) do
  73.   begin
  74.     if (check(n)) then inc(f);
  75.     if ((n.h = k.h) and (n.m = k.m) and (n.s = k.s)) then break;
  76.     n := incs(n);
  77.   end;
  78.   writeln(f);
  79. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement