Codeforces 665A. Buses Between Cities 模拟
1 second
256 megabytes
standard input
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.
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.
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.
10 30
10 35
05:20
5
60 120
24 100
13:00
9
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 模拟的更多相关文章
- codeforces 665A Buses Between Cities
简单题 #include<cstdio> #include<cstring> #include<cmath> #include<vector> #inc ...
- codeforces 665A A. Buses Between Cities(水题)
题目链接: A. Buses Between Cities time limit per test 1 second memory limit per test 256 megabytes input ...
- Educational Codeforces Round 12 A. Buses Between Cities 水题
A. Buses Between Cities 题目连接: http://www.codeforces.com/contest/665/problem/A Description Buses run ...
- CodeForces.158A Next Round (水模拟)
CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...
- Codeforces C. Jzzhu and Cities(dijkstra最短路)
题目描述: Jzzhu and Cities time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- Educational Codeforces Round 12 A. Buses Between Cities
题意: 从A到B的汽车每隔 a 分钟发车一次,从A到B要ta分钟. 从B到A汽车每隔b分钟发车一次,从B到A要ta分钟. Simion从A出发,问他在A->B的途中共遇到了多少辆车. 汽车都是从 ...
- Codeforces 703B. Mishka and trip 模拟
B. Mishka and trip time limit per test:1 second memory limit per test:256 megabytes input:standard i ...
- Codeforces 747C:Servers(模拟)
http://codeforces.com/problemset/problem/747/C 题意:有n台机器,q个操作.每次操作从ti时间开始,需要ki台机器,花费di的时间.每次选择机器从小到大开 ...
- Codeforces 740A. Alyona and copybooks 模拟
A. Alyona and copybooks time limit per test: 1 second memory limit per test: 256 megabytes input: st ...
随机推荐
- Spring中的ThreadPoolTaskExecutor
在观察线上系统的运行情况下,发现在错误日志中有这类错误信息,org.springframework.core.task.TaskRejectedException,于是便对ThreadPoolTa ...
- python的分支循环
知识内容: 1.if-else分支结构 2.while循环 3.for循环 4.循环结构综述 5.break和continue语句 一.if-else分支结构 1.单分支选择结构 if 表达式: 语句 ...
- python学习笔记一和PHP的一些对比
python和php一样是 解释性语言 php和php一样 定义变量不需要指定类型,C语言中的print函数 在python中也是适用的 python编码 适用缩进 4个空格,通常存储为UTF-8模 ...
- webserver有哪些
http://blog.csdn.net/mfsh_1993/article/details/70245380 常用web服务器有Apache.Nginx.Lighttpd.Tomcat.IBM We ...
- cookie和session的比较
cookie和session的比较 一.对于cookie: ①cookie是创建于服务器端 ②cookie保存在浏览器端 ③cookie的生命周期可以通过cookie.setMaxAge(2000); ...
- IIS ashx
win2008 IIS ashx http://127.0.0.1:801/testHandler.ashx 在服务器上用IE打开提示 HTTP 错误 404.17 - Not Found 请求的内容 ...
- J2SE 8的反射
1.获得Class的四种方式 //(1) 利用对象调用getClass()方法获取该对象的Class实例 Class<? extends ReflectTest> class1 = new ...
- WDA-FPM-4-用OVP做查询跳转到明细
转载:https://www.cnblogs.com/sapSB/p/10100697.html FPM四:用OVP做查询跳转到明细 前面做了查询的UIBB配置,在这边可以直接复用,查询的feed ...
- 泛型集合与DataSet相互转换
一.泛型转DataSet /// <summary> /// 泛型集合转换DataSet /// </summary> /// <typeparam name=" ...
- 判断TrueType字体
function IsTrueTypeFont(FontName : string) : boolean;const PITCH_MASK: byte = $0F; var TxMetric: ...