CF665A Buses Between Cities
题目描述
A 市和 B 市之间有公交车行驶,第一班是早上 $\text{5:00}$ ,最后一班不迟于 $\text{23:59}$ 开出。
从 A 市出发的公共汽车每隔 $a$ 分钟发车,到 B 市需 $t_a$ 分钟,从 B 市出发的公共汽车每隔 $b$ 分钟发一辆车,到 A 市需 $t_b$ 分钟。
司机 Simon 为了增加工作的乐趣,数了数在他的行程途中向他驶来的公交车,但 Simon 没有计算他在起点和终点遇到的公共汽车。
给定 Simon 从 A 城到 B 城的时间,计算 Simon 将会见到的公共汽车的数量。
输入格式
第一行两个整数 $a,t_a\left(1\leqslant a,t_a\leqslant 120\right)$。
第二行两个整数 $b,t_b\left(1\leqslant b,t_b\leqslant 120\right)$。
第三行一个字符串,表示 Simon 从 A 市出发的时间,格式为 $\text{hh:mm}$($\text{hh}$ 为小时,$\text{mm}$ 为分钟,且两者均用两位数表示)。
保证 Simon 从 A 市出发时一定有一辆公交车从 A 市开出,$a,t_a,b,t_b$ 的单位均为分钟。
输出格式
一行一个整数,表示 Simon 在路上遇到的公交车的数量。
说明/提示
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).