codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

665A.md (2211B)


      1 Source: https://codeforces.com/problemset/problem/665/A
      2 
      3 A. Buses Between Cities
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Buses run between the cities *A* and *B*, the first one is at 05:00 AM and the last one departs not later than at 11:59 PM. A bus from the city *A* departs every *a* minutes and arrives to the city *B* in a *t**a* minutes, and a bus from the city *B* departs every *b* minutes and arrives to the city *A* in a *t**b* minutes.
     22 
     23 The driver Simion wants to make his job diverse, so he counts the buses going towards him. Simion doesn't count the buses he meet at the start and finish.
     24 
     25 You know the time when Simion departed from the city *A* to the city *B*. Calculate the number of buses Simion will meet to be sure in his counting.
     26 
     27 Input
     28 
     29 The first line contains two integers *a*, *t**a* (1 ≤ *a*, *t**a* ≤ 120) — the frequency of the buses from the city *A* to the city *B* and the travel time. Both values are given in minutes.
     30 
     31 The second line contains two integers *b*, *t**b* (1 ≤ *b*, *t**b* ≤ 120) — the frequency of the buses from the city *B* to the city *A* and the travel time. Both values are given in minutes.
     32 
     33 The last line contains the departure time of Simion from the city *A* in the format hh:mm. It is guaranteed that there are a bus from the city *A* at that time. Note that the hours and the minutes are given with exactly two digits.
     34 
     35 Output
     36 
     37 Print the only integer *z* — the number of buses Simion will meet on the way. Note that you should not count the encounters in cities *A* and *B*.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 10 30  
     45 10 35  
     46 05:20
     47 ```
     48 
     49 Output
     50 
     51 ```
     52 5
     53 ```
     54 
     55 Input
     56 
     57 ```
     58 60 120  
     59 24 100  
     60 13:00
     61 ```
     62 
     63 Output
     64 
     65 ```
     66 9
     67 ```
     68 
     69 Note
     70 
     71 In the first example Simion departs form the city *A* at 05:20 AM and arrives to the city *B* at 05:50 AM. He will meet the first 5 buses from the city *B* that departed in the period [05:00 AM - 05:40 AM]. Also Simion will meet a bus in the city *B* at 05:50 AM, but he will not count it.
     72 
     73 Also note that the first encounter will be between 05:26 AM and 05:27 AM (if we suggest that the buses are go with the sustained speed).