A. Buses Between Cities
time limit per test:

1 second

memory 
limit per test:

256 megabytes

input:

standard input

output:

standard output

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 Aand B.

Examples
input
10 30
10 35
05:20
output
5
input
60 120
24 100
13:00
output
9
Note

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).

题目链接:http://codeforces.com/problemset/problem/665/A


题意:公交车在A,B两个城市之间运行。从A到B的公交车每隔a分钟发车一次,到达B需要ta分钟;从B到A的公交车每隔b分钟发车一次,到达A需要tb分钟。最早发车时间为上午5:00,最晚发车时间不能超过下午11:59。hh:mm出发一辆车从A出发到达B的途中会遇到多少辆公交车(不包括A,B两地)。

思路:就是求时间区间(hh:mm-tb,hh:mm+ta)内有多少辆从B到A的公交车发车。

代码:

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN = 1e5 + , mod = 1e9 + , inf = 0x3f3f3f3f;
typedef long long ll;
const ll INF = (1ll<<);
int main()
{
int a,ta,b,tb,hh,mm;
int t,s=*,e=*+;
int l=,r=;
scanf("%d%d%d%d",&a,&ta,&b,&tb);
scanf("%d:%d",&hh,&mm);
t=hh*+mm;
l=t-tb;
r=t+ta;
//cout<<l<<" "<<r<<endl;
int ans=;
while(s<=e)
{
if(s>l&&s<r) ans++;
s+=b;
if(s>r) break;
}
cout<<ans<<endl;
return ;
}

Codeforces 665A. Buses Between Cities 模拟的更多相关文章

  1. codeforces 665A Buses Between Cities

    简单题 #include<cstdio> #include<cstring> #include<cmath> #include<vector> #inc ...

  2. codeforces 665A A. Buses Between Cities(水题)

    题目链接: A. Buses Between Cities time limit per test 1 second memory limit per test 256 megabytes input ...

  3. Educational Codeforces Round 12 A. Buses Between Cities 水题

    A. Buses Between Cities 题目连接: http://www.codeforces.com/contest/665/problem/A Description Buses run ...

  4. CodeForces.158A Next Round (水模拟)

    CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...

  5. Codeforces C. Jzzhu and Cities(dijkstra最短路)

    题目描述: Jzzhu and Cities time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  6. Educational Codeforces Round 12 A. Buses Between Cities

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

  7. Codeforces 703B. Mishka and trip 模拟

    B. Mishka and trip time limit per test:1 second memory limit per test:256 megabytes input:standard i ...

  8. Codeforces 747C:Servers(模拟)

    http://codeforces.com/problemset/problem/747/C 题意:有n台机器,q个操作.每次操作从ti时间开始,需要ki台机器,花费di的时间.每次选择机器从小到大开 ...

  9. Codeforces 740A. Alyona and copybooks 模拟

    A. Alyona and copybooks time limit per test: 1 second memory limit per test: 256 megabytes input: st ...

随机推荐

  1. 常用模块:hashlib,subprocess,configparser。

    一  hashlib模块 那么我们前面学习数据类型的时候,也讲了hash,可变类型不可hash:不可变类型可hash. 我们知道hash是一种算法,接收传入的内容经过运算之后得到一个hash值,我们可 ...

  2. python-pycharm中使用anaconda部署python环境

    pycharm中使用anaconda部署python环境 今天来说一下python中一个管理包很好用的工具anaconda,可以轻松实现python中各种包的管理.相信大家都会有这种体验,在pycha ...

  3. windows巡检

    参考网站:   http://www.jb51.net/os/windows/525017.html 系统自带工具巡检  : 先说说如何检查系统健康度的方法,Win+R只有只要输入一个命令: perf ...

  4. url参数带点

    今天在处理一些接口的时候,发现了一些神奇bug. url路径参数/binbin没有问题 但是/jay.chou 发现查不到正确数据了. 其实是spring没有配置好参数带点的情况. RequestMa ...

  5. 开发者必看|Android 8.0 新特性及开发指南

    背景介绍 谷歌2017 I/O开发者大会今年将于5月17-19日在美国加州举办.大会将跟往年一样发布最新的 Android 系统,今年为 Android 8.0.谷歌在今年3 月21日发布 Andro ...

  6. Struts2:No result defined for action com.yibai.user.action.LoginAction and result input

    转自:https://zhidao.baidu.com/question/133574016.html 1 String 里面有5个static 常量分别是: ERROR INPUT LOGIN NO ...

  7. c# DbProviderFactories 多数据库支持工程模式

    DbProviderFactories.GetFactory(dbProviderName) DBProviderFactory factory = DBProviderFactorys.GetFac ...

  8. 学习写了一个点击按钮倒计时的jquery小插件

    (function($) { $.fn.extend({ getSms: function(value) { value = $.extend({ wait: 60, //参数, 默认60秒 }, v ...

  9. MVC中数据传递 ViewBag的使用

    ViewBag MVC3中 ViewBag.ViewData和TempData的使用和差别 在MVC3開始.视图数据能够通过ViewBag属性訪问.在MVC2中则是使用ViewData.MVC3中保留 ...

  10. JS 判断鼠标滚轮的上下滚动

    JS 判断鼠标滚轮的上下滚动   <script type="text/javascript"> var scrollFunc = function (e) { e = ...