CodeForces 665A Buses Between Cities
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
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
struct Node{
int l,r;
}a1[10005];
int a,ta;
int b,tb;
int hh,mm;
int time(int hh,int mm){
return hh*60+mm;
}
int main(){
scanf("%d%d",&a,&ta);
scanf("%d%d",&b,&tb);
scanf("%d:%d",&hh,&mm);
int start=time(5,0);
int end=time(23,59);
int cnt=0;
while(start<=end)
{
a1[cnt].l=start;
a1[cnt].r=a1[cnt++].l+tb;
start+=b;
}
Node b1;b1.l=time(hh,mm);b1.r=b1.l+ta;
int ans=0;
for(int i=0;i<cnt;i++)
{
if(b1.r>a1[i].l&&b1.l<a1[i].r)
ans++;
}
printf("%dn",ans);
return 0;
}
- 机器学习实践:用 Spark 和 DBSCAN 对地理定位数据进行聚类
- 【Golang语言社区】H5游戏开发从零开始开发一款H5小游戏(三) 攻守阵营,赋予粒子新的生命
- 【H5游戏实例】JS+canvas实现人机大战之五子棋
- Go包管理的探索与实践
- 机器学习优化算法之爬山算法小结
- 机器学习之最小二乘法
- Go中的同步与锁
- 机器学习之KNN算法思想及其实现
- 机器学习之决策树熵&信息增量求解算法实现
- 朴素贝叶斯分类器(离散型)算法实现(一)
- spring设置全局异常处理器
- discuz论坛apache日志hadoop大数据分析项目:hive以及hbase是如何入库以及代码实现
- 【Golang语言社区】前端编程- 从零开始开发一款H5小游戏(一) 重温canvas的基础用法
- 今天聊聊分布式锁 No.86
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- Android使用手势实现翻页效果
- Android应用内悬浮窗的实现方案示例
- Android实现View拖拽跟随手指移动效果
- Android中button的onClick事件几种方法
- Android利用Glide获取图片真正的宽高的实例
- Android 自定义AlertDialog对话框样式
- Android自定义一个图形单点移动缩小的效果
- 详解Android实现购物车页面及购物车效果(点击动画)
- Android利用LitePal操作数据库存取图片
- Android 改变图标原有颜色和搜索框的实例代码
- Android自定义滑动验证条的示例代码
- Android实现图片转高斯模糊以及高斯模糊布局
- android多媒体类VideoView使用方法详解
- Android编程实现短信收发及语音播报提示功能示例
- Android viewpager无限轮播获取网络图片功能