A10460 | Buses Between Cities
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 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.
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).
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).
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted