A. Buses Between Cities

题目连接:

http://www.codeforces.com/contest/665/problem/A

Description

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 ta minutes, and a bus from the city B departs every b minutes and arrives to the city A in a tb 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.

Input

The first line contains two integers a, ta (1 ≤ a, ta ≤ 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, tb (1 ≤ b, tb ≤ 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.

Output

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.

Sample Input

10 30

10 35

05:20

Sample Output

5

Hint

题意

有两个城市A,B。

每a分钟A会发一趟车,这辆车会走TA秒到达B。

每b分钟B会发一趟车,这辆车会走TB秒到达A。

两个城市从早上5点开始发车,11点停止发车

有一个小朋友,坐着从A到B的列车,问他能够看到多少辆车

题解:

看到的车显然就是在这辆车行进的这个时间段内,B地才开始发车的和没有到的那些车。

然后暴力一波就好了~

代码

#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,ta,b,tb;
scanf("%d%d%d%d",&a,&ta,&b,&tb);
int h,m;scanf("%d:%d",&h,&m);
m+=60*h;
int ans = 0;
for(int i=300;i<24*60;i+=b)
if(i+tb>m&&i<m+ta)ans++;
cout<<ans<<endl;
}

最新文章

  1. Maven依赖包下载慢--阿里云让你飞
  2. MVC4中 访问webservice 出现无法找到资源的错误
  3. URAL 1167. Bicolored Horses (DP)
  4. HDU 5491 The Next
  5. ASP.NET用SQL Server中的数据来生成JSON字符串
  6. UESTC_Ferris Wheel String 2015 UESTC Training for Search Algorithm &amp; String&lt;Problem L&gt;
  7. openGL 旋转的图形 矩阵操作
  8. [原]使用MachOView辅助破解AppStore应用
  9. java基础:数组查询,同一数组一个元素最多出现两次
  10. 遗传算法解决TSP问题实现以及与最小生成树的对比
  11. 前端笔记之jQuery(上)加载函数的区别&amp;对象&amp;操作HTML/CSS&amp;动画&amp;选择器
  12. linux 基础(一)
  13. 前端——BOM和DOM
  14. RESTful levels、HATEOAS
  15. ThreadLocal类的简单使用
  16. 三次样条插值算法C++实现
  17. 安装ReactNative开发IDE
  18. 我们为什么需要Map-Reduce?
  19. 前端(八):react入门
  20. redis主从,哨兵,集群

热门文章

  1. 28 - 生成器交互-__slots__-未实现异常
  2. linux下C语言实现的内存池【转】
  3. SSL证书生成方法【转】
  4. java中String的==和equals的区别
  5. WPF之换肤
  6. SipDroid +miniSIPServer搭建SIP局域网语音通话(一)
  7. linux 实现自动创建ftp用户并创建文件夹
  8. Django 1.10文档中文版Part2
  9. linux自动获得mac地址,修改网络配置
  10. 基于Token的授权(with srping mvc)