303432: CF665A. Buses Between Cities

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Buses Between Cities

题意翻译

### 题目大意 $A$市和$B$市之间有公交车行驶,第一班是早上$5:00$,最后一班不迟于晚上$11:59$开出。 从$A$市出发的公共汽车每隔$a$分钟发车,到$B$市需$t_a$分钟,从$B$市出发的公共汽车每隔$b$分钟发一辆车,到$A$市需$t_b$分钟。 司机$Simon$~~吃饱了没事干~~增加工作的乐趣,数了数在他的行程途中向他驶来的公交车,但$Simon$没有计算他在起点和终点遇到的公共汽车。 给定$Simon$从$A$城到$B$城的时间,计算Simon将会见到的公共汽车的数量。 ### 输入格式 第一行:两个整数$a$与$t_a$$(1\le a,t_a\le 120)$。 第二行:两个整数$b$与$t_b$$(1\le b,t_b\le 120)$。 ps:$a,t_a,b,t_b$单位均为分钟。 第三行:$Simon$从$A$市出发的时间,格式:$hh:mm$(h为小时,m为分钟,且两者均用两位数表示)。 ps:$Simon$从$A$市出发时一定有一辆公交车从$A$市开出。 ### 输出格式 一个整数$z$,表示$Simon$在路上遇到的公交车的数量。 $(translated$ $by$ $DreamingBoyWonders)$

题目描述

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. 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. 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.

输入输出格式

输入格式


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. 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. 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.

输出格式


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 $ .

输入输出样例

输入样例 #1

10 30
10 35
05:20

输出样例 #1

5

输入样例 #2

60 120
24 100
13:00

输出样例 #2

9

说明

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. 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).

Input

题意翻译

### 题目大意 $A$市和$B$市之间有公交车行驶,第一班是早上$5:00$,最后一班不迟于晚上$11:59$开出。 从$A$市出发的公共汽车每隔$a$分钟发车,到$B$市需$t_a$分钟,从$B$市出发的公共汽车每隔$b$分钟发一辆车,到$A$市需$t_b$分钟。 司机$Simon$~~吃饱了没事干~~增加工作的乐趣,数了数在他的行程途中向他驶来的公交车,但$Simon$没有计算他在起点和终点遇到的公共汽车。 给定$Simon$从$A$城到$B$城的时间,计算Simon将会见到的公共汽车的数量。 ### 输入格式 第一行:两个整数$a$与$t_a$$(1\le a,t_a\le 120)$。 第二行:两个整数$b$与$t_b$$(1\le b,t_b\le 120)$。 ps:$a,t_a,b,t_b$单位均为分钟。 第三行:$Simon$从$A$市出发的时间,格式:$hh:mm$(h为小时,m为分钟,且两者均用两位数表示)。 ps:$Simon$从$A$市出发时一定有一辆公交车从$A$市开出。 ### 输出格式 一个整数$z$,表示$Simon$在路上遇到的公交车的数量。 $(translated$ $by$ $DreamingBoyWonders)$

加入题单

算法标签: