Codeforces Round #438 B. Race Against Time 题解
来源:互联网 发布:家具软件管理 编辑:程序博客网 时间:2024/06/07 23:13
B. Race Against Time
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
Have you ever tried to explain to the coordinator, why it is eight hours to the contest and not a single problem has been prepared yet? Misha had. And this time he has a really strong excuse: he faced a space-time paradox! Space and time replaced each other.
The entire universe turned into an enormous clock face with three hands — hour, minute, and second. Time froze, and clocks now show the time h hours, m minutes, s seconds.
Last time Misha talked with the coordinator at t1 o’clock, so now he stands on the number t1 on the clock face. The contest should be ready by t2 o’clock. In the terms of paradox it means that Misha has to go to number t2 somehow. Note that he doesn’t have to move forward only: in these circumstances time has no direction.
Clock hands are very long, and Misha cannot get round them. He also cannot step over as it leads to the collapse of space-time. That is, if hour clock points 12 and Misha stands at 11 then he cannot move to 1 along the top arc. He has to follow all the way round the clock center (of course, if there are no other hands on his way).
Given the hands’ positions, t1, and t2, find if Misha can prepare the contest on time (or should we say on space?). That is, find if he can move from t1 to t2 by the clock face.
Input
Five integers h, m, s, t1, t2 (1 ≤ h ≤ 12, 0 ≤ m, s ≤ 59, 1 ≤ t1, t2 ≤ 12, t1 ≠ t2).
Misha’s position and the target time do not coincide with the position of any hand.
Output
Print “YES” (quotes for clarity), if Misha can prepare the contest on time, and “NO” otherwise.
You can print each character either upper- or lowercase (“YeS” and “yes” are valid when the answer is “YES”).
Examples
input
12 30 45 3 11
output
NO
input
12 0 1 12 1
output
YES
input
3 47 0 4 9
output
YES
Note
The three examples are shown on the pictures below from left to right. The starting position of Misha is shown with green, the ending position is shown with pink. Note that the positions of the hands on the pictures are not exact, but are close to the exact and the answer is the same.
就是算指针区间,注意是按时间算,不是直接按数据算
#include <bits/stdc++.h>#define INF 2100000000#define LL long long#define clr(x) memset(x, 0, sizeof x)#define ms(a, x) memset(x, a, sizeof x)using namespace std;const int maxn = 105;double h,m,s,t1,t2;int flag1,flag2;int main() { scanf("%lf%lf%lf%lf%lf",&h,&m,&s,&t1,&t2); if(h == 12) h = 0; h += m/60+s/3600; h *= 30.0; m += s/60; m *= 6.0; s *= 6.0; t1 *= 30.0; t2 *= 30.0; if(t1 > t2) swap(t1, t2); if(h >= t1 && h <= t2 || m >= t1 && m <= t2 || s >= t1 && s <= t2) { printf("NO"); return 0; } if(t1 <= 180) t1 += 360; if(t2 <= 180) t2 += 360; if(h <= 180) h += 360; if(m <= 180) m += 360; if(s <= 180) s += 360; if(h >= t1 && h <= t2 || m >= t1 && m <= t2 || s >= t1 && s <= t2) printf("NO"); else printf("YES"); return 0;}
- Codeforces Round #438 B. Race Against Time 题解
- Codeforces Round #438 B. Race Against Time
- Codeforces Round #438 (868B) B Race Against Time
- Codeforces Round #438 B. Race Against Time 思路很重要
- Codeforces Round #438 B Race Against Time(模拟)
- Codeforces Round #438 (Div. 1 + Div. 2 combined) B. Race Against Time(模拟)
- Codeforces Round #438 (Div. 1 + Div. 2 combined) B. Race Against Time
- CodeFroces Round 438 B.Race Against Time(模拟)
- codeforces 868B Race Against Time
- Codeforces 868B. Race Against Time 模拟
- 【Codeforces 868 B. Race Against Time】& 模拟
- CodeForces 868B Race Against Time
- codeforces 868B Race Against Time
- Codeforces 868 B Race Against Time(水题)
- CF 868 B. Race Against Time【模拟】
- Codeforces868B Race Against Time
- Codeforce Race Against Time
- SPOJ 3261. Race Against Time(RACETIME)(分块)
- 秒杀系统(感悟&待续)
- Cacti 邮件 报警
- 移动混合开发,国内镜像及局域网Ionic+Cordova配置
- 方法的重载与重写 区别 封装 继承 多态
- IntelliJ Idea 免费激活方法 2017
- Codeforces Round #438 B. Race Against Time 题解
- Android数据存储之ContentProvider
- 在Idea中遇到Usage of API documents as @since 1.6+ 错误
- 高级程序设计读书笔记(一)
- 模拟UA(user agent)实现访问只能在微信上打开的网页
- 静态链接的过程
- asp.net 不同应用程序在IIS发布后实现Session共享
- juqery--获取json数据后一次性填充表单数据的方法
- 影响机器视觉光源效果的因素有哪些?