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;
}

Educational Codeforces Round 12 A. Buses Between Cities 水题相关推荐

  1. Educational Codeforces Round 103 (Rated for Div. 2)前四题

    Educational Codeforces Round 103 (Rated for Div. 2) 第二次被别人hack,悲 A - K-divisible Sum 题意 给定两个整数 n,kn, ...

  2. Educational Codeforces Round 12 C. Simple Strings 贪心

    C. Simple Strings 题目连接: http://www.codeforces.com/contest/665/problem/C Description zscoder loves si ...

  3. Educational Codeforces Round 12 D. Simple Subset 最大团

    D. Simple Subset 题目连接: http://www.codeforces.com/contest/665/problem/D Description A tuple of positi ...

  4. Educational Codeforces Round 12 B. Shopping 暴力

    B. Shopping 题目连接: http://www.codeforces.com/contest/665/problem/B Description Ayush is a cashier at ...

  5. Educational Codeforces Round 100 (Rated for Div. 2)补题记录

    总结:感觉这个educational场好难啊(蒟蒻视角),又被虐了,唉 A. Dungeon 每一枪会造成1点伤害对一个单位,但是当开7的倍数枪时会造成3点伤害 每7次一个轮回,一个完整的轮回共造成9 ...

  6. Educational Codeforces Round 133 (Rated for Div. 2) D题

    题目链接:Problem - D - Codeforces 一道非常经典的完全背包求方案数题: 首先先写好我们的状态转移方程,那什么代表体积,什么代表物品数目呢: 其实很清晰k, k + 1 ... ...

  7. Educational Codeforces Round 33 (Rated for Div. 2) B题

    B. Beautiful Divisors Recently Luba learned about a special kind of numbers that she calls beautiful ...

  8. Educational Codeforces Round 131 (Rated for Div. 2)刷题记录OR题解

    题解 A Grass Field 题面翻译 给出一个 2×22 \times 22×2 的矩阵,矩阵的值都是 000 和 111,定义一次操作:选择一个点,将其所在的行和列的点的值全部修改为 000, ...

  9. codeforces Educational Codeforces Round 49 (Rated for Div. 2) C题

    刚开始拿到这题很懵逼,知道了别人的思路之后开始写,但是还是遇到很多坑,要求求P2/S最大.p=a b.就是求(a2+ b2 +2ab)/ab最大,也就是a/b +b/a最大.那么题意就很明显了. 但是 ...

最新文章

  1. 【Mysql】MySQL与Oracle的大小写问题
  2. docker部署项目,对镜像,容器的操作
  3. angular的性能分析 -随记
  4. inputstream读取html乱码,java InputStream 读取汉语言内容的解决乱码
  5. java对象和json对象之间互相转换
  6. Modbus协议栈应用实例之四:ModbusTCP服务器应用
  7. Pytorch —— 模型保存与加载
  8. Android Tween动画之RotateAnimation实现图片不停旋转
  9. 网站安全之设置HttpOnly的方法
  10. 分享小知识:善用Group By排序
  11. HDU2516 取石子游戏
  12. 小米:做全球最好的手机,成就最大AIoT生态
  13. GDPR: Impact to Your Data Management Landscape: Part 1
  14. Python遍历字典的几种方式
  15. 一个关于中国省市区的字典,数组嵌套使用
  16. DELPHI 6的INFOPOWER 3000汉化
  17. IIS之web服务器的安装、部署以及使用教程(图文详细版)
  18. 浙江数字贸易先行示范区建设方案发布,贡献数字贸易“浙江方案”
  19. Socket之文件下载
  20. 题目:L2-031 深入虎穴 (25 分)

热门文章

  1. PowerToys,微软开源的超实用小工具合集
  2. Activity的生命周期是谁调用的?
  3. 编写 DockerFile
  4. [原]Failed to load SELinux policy. System Freezing ----redhat7or CentOS7 bug
  5. Python:高级主题之(属性取值和赋值过程、属性描述符、装饰器)
  6. 事件源event.target
  7. 设置Windows7各种睡眠方式
  8. 【我看Hibernate】Hibernate 介绍及其简单应用
  9. .net中6个重要的基础概念:Stack, heap, Value types, reference types, boxing and Unboxing.
  10. error MIDL2025/2026