fork(1) download
  1. import java.util.*;
  2.  
  3. class Task3
  4. {
  5. public static void main (String[] args)
  6. {
  7. int m1,m2,h1,h2, rings = 0;
  8. Scanner in = new Scanner(System.in);
  9. h1 = in.nextInt();
  10. m1 = in.nextInt();
  11. h2 = in.nextInt();
  12. m2 = in.nextInt();
  13. in.close();
  14.  
  15. while (true)
  16. {
  17. if (m1 == 0)
  18. rings += (h1==0 || h1==12)?12:h1%12;
  19.  
  20. if (m1 == 30)
  21. rings += 1;
  22.  
  23. if (m1 == m2 && h1 == h2)
  24. break;
  25.  
  26. m1 ++ ;
  27. if (m1 > 60)
  28. {
  29. m1 = 0;
  30. h1 ++ ;
  31. }
  32. }
  33. System.out.println(rings);
  34. }
  35. }
Success #stdin #stdout 0.06s 4386816KB
stdin
16
57
16
57
stdout
0