CodeForces 665A Buses Between Cities
来源:互联网 发布:大数据 行业专家 编辑:程序博客网 时间:2024/06/05 14:37
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 3010 3505:20
5
60 12024 10013:00
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("%d\n",ans);return 0;}
- CodeForces 665A Buses Between Cities
- CodeForces 665A Buses Between Cities
- Codeforces 665A - Buses Between Cities
- Educational Codeforces Round 12 A. Buses Between Cities
- Educational Codeforces Round 12 A. Buses Between Cities
- cf655A Buses Between Cities
- Buses Between Cities
- codeforces 101 B. Buses
- hdu2874 Connections between cities
- HDU Connections between cities
- HDU2874 Connections between cities
- Connections between cities
- Connections between cities
- hdu2874 Connections between cities
- Connections between cities
- Connections between cities HDU
- Connections between cities HDU
- CodeForces 867A Between the Offices
- 关于java的反射机制及动态代理
- 人生感悟(一)离职
- Redis学习笔记(3)-XShell连接CentOSMini,并安装Redis
- linux下面的fd限制
- 在子视图中获取父视图的控制器
- CodeForces 665A Buses Between Cities
- hjr教程-Android(三):关于Log
- 转载 本机运行x程序出现:Can't open display 原因及其解决方法
- Caused by: android.content.res.Resources$NotFoundException: File res/drawable/main_tab_conversation_
- 把不带前缀的域名转向到www.域名的Apache 301转向配置样例
- typedef vs #define
- HTTP Live Streaming直播(iOS直播)技术分析与实现
- 树形结构数据后台处理:一次循环生成树
- CentOS7执行ifconfig Command not found 未找到命令