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. MUI上传文件的方法

    <!doctype html> <html> <head> <meta charset="UTF-8"> <title> ...

  2. 初识smarty

    个人体会(不完全正确):就是smarty就是为了更好的使得php/html结合做出来的一个框架. ,

  3. 谷歌PageRank算法

    1. 从Google网页排序到PageRank算法 (1)谷歌网页怎么排序? 先对搜索关键词进行分词,如“技术社区”分词为“技术”和“社区”: 根据建立的倒排索引返回同时包含分词后结果的网页: 将返回 ...

  4. centos上Jenkins搭建

    Jenkins可以提供持续集成服务,它的运行环境(runtime)需要Tomcat和JDK 要把Jenkins让Tomcat启动服务,而Tomcat需要JDK的环境 详情配置参见: http://ww ...

  5. u-boot界面添加命令[demo]

    目标板:2440 如何在u-boot界面中增加命令 在/common/目录下建立文件,调用执行函数do_bootm就行,然后在修改Makefile,就OK了. 比如在u-boot界面添加命令test ...

  6. acm专题---dfs+bfs

    题目来源:http://hihocoder.com/problemset/problem/1049 #1049 : 后序遍历 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描 ...

  7. plsql例子

    create or replace procedure find_difference(db_link in varchar2) is /* 比对两套环境建表脚本差异,以224环境为主 当前环境,db ...

  8. 邀请用户进TestFlight 体验 App 的测试版本

    iphone手机用户,在工作中常见到,APP版本现在是Beta阶段(iOS版本),需要邀请一些用户来体验新版本,在版本上线前提出更好的建议及时进行修改,此时用到了testflight,很方便的通过邀请 ...

  9. powerdeginer 默认name 为 common

    在使用PowerDesigner对数据库进行概念模型和物理模型设计时,一般在NAME或Comment中写中文,在Code中写英文.Name用来显 示,Code在代码中使用,但Comment中的文字会保 ...

  10. [实战]MVC5+EF6+MySql企业网盘实战(6)——ajax方式登录

    写在前面 今天回来的比较早,就趁着有空,把登录的代码更新一下.上篇文章实现了ajax的注册,这篇将实现登录,实现目标,ajax登录方式,如果勾选记住我,则下次不再输入用户名密码,直接跳转到网盘界面. ...