CodeForces
来源:互联网 发布:网络电视看电视直播 编辑:程序博客网 时间:2024/05/29 15:32
Race Against Time
题目链接:Race Against Time
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.
题意:在不经过时针分针秒针的情况下,能不能从第t1点到t2点(顺时针逆时针都行)
思路:先把所有时间都转换为60单位的形式,然后直接模拟
代码:
#include<stdio.h>#include<algorithm>using namespace std;int main(){ double h,m,s,t1,t2; scanf("%lf%lf%lf%lf%lf",&h,&m,&s,&t1,&t2); m=m+s/60.0; h=(h+m/60.0)*5.0; if(m>=60.0) m-=60.0; if(h>=60.0) h-=60.0; t1*=5.0,t2*=5.0; if(t1>t2) swap(t1,t2); int flag1=1,flag2=1; if((t1<=h&&h<=t2)||(t1<=m&&m<=t2)||(t1<=s&&s<=t2))//从较小的点到较大的点 flag1=0; if(h<=t1) h+=60.0; if(m<=t1) m+=60.0; if(s<=t1) s+=60.0; t1+=60.0; if((t2<=h&&h<=t1)||(t2<=m&&m<=t1)||(t2<=s&&s<=t1))//从较大的点到较小的点 flag2=0; if(flag1||flag2) printf("YES\n"); else printf("NO\n"); return 0;}
- codeforces~~~
- Codeforces
- codeforces
- Codeforces
- codeforces
- codeforces
- Codeforces
- Codeforces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- 排序算法-堆排序
- Java类初始化顺序
- 虽然微不足道但是很有用的JAVA基础—编程语言的类型
- 设计模式-(3)抽象工厂
- 实验二 线性表综合实验(双链表)
- CodeForces
- 每日英语阅读(六十五)
- 使用pip安装numpy遇到问题
- SmartThreadPool
- c#获取网页源代码的5种方式
- Python模块学习笔记
- 青鸟微信群邀请统计
- css top与bottom属性
- bzoj 1933: [Shoi2007]Bookcase 书柜的尺寸