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 12 A. Buses Between Cities

    题意: 从A到B的汽车每隔 a 分钟发车一次,从A到B要ta分钟. 从B到A汽车每隔b分钟发车一次,从B到A要ta分钟. Simion从A出发,问他在A->B的途中共遇到了多少辆车. 汽车都是从 ...

  2. Educational Codeforces Round 14 A. Fashion in Berland 水题

    A. Fashion in Berland 题目连接: http://www.codeforces.com/contest/691/problem/A Description According to ...

  3. Educational Codeforces Round 13 C. Joty and Chocolate 水题

    C. Joty and Chocolate 题目连接: http://www.codeforces.com/contest/678/problem/C Description Little Joty ...

  4. Educational Codeforces Round 4 A. The Text Splitting 水题

    A. The Text Splitting 题目连接: http://www.codeforces.com/contest/612/problem/A Description You are give ...

  5. Codeforces Educational Codeforces Round 3 B. The Best Gift 水题

    B. The Best Gift 题目连接: http://www.codeforces.com/contest/609/problem/B Description Emily's birthday ...

  6. Codeforces Educational Codeforces Round 3 A. USB Flash Drives 水题

    A. USB Flash Drives 题目连接: http://www.codeforces.com/contest/609/problem/A Description Sean is trying ...

  7. Educational Codeforces Round 13 D. Iterated Linear Function 水题

    D. Iterated Linear Function 题目连接: http://www.codeforces.com/contest/678/problem/D Description Consid ...

  8. Educational Codeforces Round 13 B. The Same Calendar 水题

    B. The Same Calendar 题目连接: http://www.codeforces.com/contest/678/problem/B Description The girl Tayl ...

  9. Educational Codeforces Round 13 A. Johny Likes Numbers 水题

    A. Johny Likes Numbers 题目连接: http://www.codeforces.com/contest/678/problem/A Description Johny likes ...

随机推荐

  1. ValueList用法

    ValueList的OverView 概述 在很多情况下,使用JDBC是很繁琐的,有很多方法可以替换JDBC,比如JDO.Hibernate等. 即使在从service中接收POJO的List的解决方 ...

  2. Linux Kernel代码艺术——数组初始化【转】

    转自:http://www.cnblogs.com/hazir/p/array_initialization.html 前几天看内核中系统调用代码,在系统调用向量表初始化中,有下面这段代码写的让我有点 ...

  3. ovirt系统磁盘删除后清理功能验证步骤

    测试步骤主要是针对ovirt系统磁盘的‘删除后清理’功能,如下图所示: 测试如下两种方式: 预置条件: 搭建iscsi服务器,且划分一个11G的盘 勾选删除后清理操作步骤:1 .在linux虚拟机 d ...

  4. javaScript如何跳出多重循环break、continue

    先来说说break和continue之间的区别 for(var i=0;i<10;i++){  if(i>5){  break;  }}console.log(i);  ---6  •当i ...

  5. 20165301 2017-2018-2 《Java程序设计》第五周学习总结

    20165301 2017-2018-2 <Java程序设计>第五周学习总结 教材学习内容总结 第七章:内部类与异常类 内部类 在一个类中定义另一个类 非内部类不可以是static类 匿名 ...

  6. EasyUi–8.datebox赋值的问题

    这个问题要从EasyUI的datebox组件说起,小菜用这个组件的时候,发现用$("#id").val()这种形式,居然拿不到文本框的值! 经过度娘的帮助,发现可以用$(" ...

  7. django orm如何作一个优雅一点的filter?

    如果有N多fitler条件, 单独放在一个长语句里显然不好看. 还好, django支持字典方式的过滤条件, 写法大约与单独的长语里差不多. 如下: def get_queryset(self): f ...

  8. 作死自救日记——不小心修改linux下/etc/sudoers权限的解决办法

    作死自救日记,献给跟我一样不小心作了死的人 ================================================ 今天不小心作死修改了/etc/sudoers的权限,作死命 ...

  9. NIO-3网络通信

    import java.io.IOException; import java.net.InetSocketAddress; import java.nio.ByteBuffer; import ja ...

  10. day4 装饰器深入解析

    Python装饰器 装饰器是在不修改源码给代码添加功能的常用方法.@是装饰的标志.我们知道,在给代码增加功能的时候,要遵循开放封闭的原则,不能随便更改原码,因此装饰器的功能就显示出来了,只需要在函数前 ...