fork(3) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int h1, m1, h2, m2, result = 0;
  6. cin >> h1 >> m1 >> h2 >> m2;
  7. while(true) {
  8. if(m1 == 0) {
  9. result += h1 > 12 ? h1 - 12 : h1 == 0 ? 12 : h1;
  10. } else if(m1 == 30) {
  11. result++;
  12. }
  13. if(h1 == h2 && m1 == m2) {
  14. break;
  15. }
  16. m1++;
  17. if(m1 == 60) {
  18. m1 = 0;
  19. h1++;
  20. }
  21. }
  22. cout << result << endl;
  23. return 0;
  24. }
Success #stdin #stdout 0s 3464KB
stdin
13 30 15 10
stdout
7