CodeForces 665A Buses Between Cities

本文介绍了一个简单的编程问题,即计算司机Simion从城市A到城市B的路上会遇到多少辆来自对方城市的公交车。输入包括两组频率及行程时间,以及Simion出发的时间。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

思路:水题


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

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

Sample Input

Input
10 30
10 35
05:20
Output
5
Input
60 120
24 100
13:00
Output
9


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值