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 ...
随机推荐
- How to Create a Provisioning Profile for iPhone
If you're making iPhone and iPad apps, there are some processes you must work through to go from dev ...
- .NET组件编程
链接 http://www.cnblogs.com/mapserver/archive/2006/03/06/343632.html
- Linux中的热键[Tab] [Ctrl]-c [Ctrl]-d
Tab键:命令或者文件补全.可以避免很多的输入错误 1. 按一次,文件或命令补全 2. 按两次,会列举出以按键前的字母为首的所有命令或者文件 Ctrl+C:中断目前程序 Ctrl+D:键盘输入结束.可 ...
- 如何在Linux中使用sFTP上传或下载文件与文件夹
如何在Linux中使用sFTP上传或下载文件与文件夹 sFTP(安全文件传输程序)是一种安全的交互式文件传输程序,其工作方式与 FTP(文件传输协议)类似. 然而,sFTP 比 FTP 更安全;它通过 ...
- Git使用笔记01
本文基本的參考文章链接例如以下所看到的: Pro Git(中文版) Git教程 Git使用教程 简单介绍与说明 Git是一个分布式版本号管理系统,是为了更好地管理Linux内核开发而创立的.Git能够 ...
- vue2 + typescript2 项目开发(环境配置)
Vue 引入 TypeScript vue init airyland/vux2 projectName 增加开发包的依赖 npm install typescript ts-loader --sav ...
- sonar + ieda实现提交代码前代码校验
代码风格不同一直是一件停头疼的事情,因为不同的工作经验,工作经历,每个人的代码风格不尽相同,造成一些代码在后期的维护当中难以维护, 查阅一些资料之后发现 idea + sonar 的方式比较适合我,实 ...
- Java爬虫快速开发工具uncs的部署攻略
写在前面 uncs是java快速开发爬虫的工具,简单便捷,经过大量版本迭代和生产验证,可以适用大多数网站,推荐使用. 一.基本用法 1.1 开发包获取 目前只能在公司内网maven服务器获取到 < ...
- 分享一个小工具:Excel表高速转换成JSON字符串
在游戏项目中一般都须要由策划制作大量的游戏内容,当中非常大一部分是使用Excel表来制作的.于是程序就须要把Excel文件转换成程序方便读取的格式. 之前项目使用的Excel表导入工具都是通过Offi ...
- java四种线程池简介,使用
为什么使用线程池 1.减少了创建和销毁线程的次数,每个工作线程都可以被重复利用,可执行多个任务. 2.可以根据系统的承受能力,调整线程池中工作线线程的数目,防止消耗过多的内存 3.web项目应该创建统 ...