codeforces 665A A. 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).
题意:
给出每隔多少分钟发车和经过多长时间到达目的地,为给的其中一辆车的发车时间,问这个车的司机能在路上遇到到多少辆车;
思路:
遇到的车都是到达时间在这辆车的发车时间之后和发车时间在这辆车到达时间之前的
AC代码:
/*2014300227 665A - 17 GNU C++11 Accepted 15 ms 2172 KB*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+;
const ll mod=1e9+;
int a,ta,b,tb;
char str[],s;
int main()
{
scanf("%d%c%d",&a,&s,&ta);
scanf("%d%c%d",&b,&s,&tb);
scanf("%s",str);
int start=((str[]-'')*+(str[]-''))*+(str[]-'')*+(str[]-'');
int ending=start+ta;
int l=,r=*-;
int ans=;
for(int i=l;i<=r;i+=b)
{
if(i+tb>start&&i<ending)ans++;
}
cout<<ans<<"\n";
return ;
}
codeforces 665A A. Buses Between Cities(水题)的更多相关文章
- Educational Codeforces Round 12 A. Buses Between Cities 水题
A. Buses Between Cities 题目连接: http://www.codeforces.com/contest/665/problem/A Description Buses run ...
- Educational Codeforces Round 7 B. The Time 水题
B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...
- Educational Codeforces Round 7 A. Infinite Sequence 水题
A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/622/problem/A Description Consider the ...
- Codeforces Testing Round #12 A. Divisibility 水题
A. Divisibility Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/probl ...
- Codeforces Beta Round #37 A. Towers 水题
A. Towers 题目连接: http://www.codeforces.com/contest/37/problem/A Description Little Vasya has received ...
- codeforces 677A A. Vanya and Fence(水题)
题目链接: A. Vanya and Fence time limit per test 1 second memory limit per test 256 megabytes input stan ...
- CodeForces 690C1 Brain Network (easy) (水题,判断树)
题意:给定 n 条边,判断是不是树. 析:水题,判断是不是树,首先是有没有环,这个可以用并查集来判断,然后就是边数等于顶点数减1. 代码如下: #include <bits/stdc++.h&g ...
- Codeforces - 1194B - Yet Another Crosses Problem - 水题
https://codeforc.es/contest/1194/problem/B 好像也没什么思维,就是一个水题,不过蛮有趣的.意思是找缺黑色最少的行列十字.用O(n)的空间预处理掉一维,然后用O ...
- Codeforces 1082B Vova and Trophies 模拟,水题,坑 B
Codeforces 1082B Vova and Trophies https://vjudge.net/problem/CodeForces-1082B 题目: Vova has won nn t ...
随机推荐
- 编译php ./configure命令enable和with有什么区别
原文: https://segmentfault.com/q/1010000009174725 ---------------------------------------------------- ...
- 记事本中写c/c++程序在Windows下运行
1.在桌面新建一个1.c,内容例如以下: 2.打开cmd命令行窗体,进入CodeBlock安装文件夹下的:E:\Installed\CodeBlocks\MinGW.然后运行mingwvars. ...
- 判断浏览器是否支持flash
虽然flash已经过时了,如腾讯视频一样,有很多网站还来不及或者根本就改不了原来的架构,所以我们需要判断flash视频(默认chrome和Firefox)等浏览器会自动阻止flash加载 , 这与Sa ...
- PHP_EOL是什么意思?
PHP_EOL 代表php的换行符, 这个变量会根据平台而变, 在windows下会是/r/n, 在linux下是/n, 在mac下是/r 文章来源:刘俊涛的博客 地址:h ...
- odoo秘密入口
可以通过往 odoo进程 发送 "信号",让odoo干一些特定的工作 例如 kill -s SIGUSR1 pid , 将打印输出 cache统计 信号 作用 说明 ...
- java web 站点头像上传处理 (springmvc +bootstrap+cropper)
制作头像上传.请依据您的实际需求.改动代码,不全然正确.仅供參考! 前端页面设计使用bootstrap ,头像预览和剪裁工具使用cropper 后台使用springmvc. 如今来看前端的页面设计 前 ...
- linux基础(5)- nginx服务、nfs服务
一.nginx服务 源码安装: yum install gcc-* glibc-* openssl openssl-devel pcre pcre-devel zlib zlib-devel -yls ...
- Python 模块之 ConfigParser: 用 Python 解析配置文件
在程序中使用配置文件来灵活的配置一些参数是一件很常见的事情,配置文件的解析并不复杂,在 Python 里更是如此,在官方发布的库中就包含有做这件事情的库,那就是 ConfigParser,这里简单的做 ...
- 小贝_mysql select连接查询
select连接查询 简要: 一.union联合查询 二.左右内连接 一.union联合查询 作用: 把2次或多次查询结果合并起来 具体: (表1查询结果) union (表2查询结果) 运行: 先算 ...
- java中使用opencv
Java + opencv学习:在Eclipse下配置基于Java的OpenCV开发环境 2016-04-08 17:43 6491人阅读 评论(0) 收藏 举报 分类: OpenCV学习(10) ...