传送门
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.
题目意思:在一个圆状时钟上,给你一个时间:h:m:s, 再给你钟表上的两个位置:t1,t2; 求t1可以不可以毫无阻碍得走到t2的位置(或者说t2->t1也可以)。主要坑的点在于如何表示有没有表针存在于t1,t2之间。可以根据所给时间求得每个表针相对于“12”这个位置所偏离的角度。单位换算,即可,注意时针的位置也受分针和秒针的影响,分针的位置也受秒针的影响, 最后再[t1,t2]区间内有没有表针或者有三个表针即可。
真的是菜哇,做题的时候竟然脑袋秀逗了,掉分掉分,今天看rating看到还有负分的,感觉是故意的。。
AC_code:
#include<bits/stdc++.h>
using namespace std;
int a,b;
int OK(double x){
if(x>a&&x<b)
return 1;
else
return 0;
}
struct Point{
int hh,mm,ss;
void Set(){
cin>>hh>>mm>>ss;
hh%=12;
}
void solve(){
double h = hh*30+mm*0.5+ss/120.0;
double m = mm*6.0+ss*1.0/60.0;
double s = ss*6.0;
int xx=0;
xx+=OK(h);
xx+=OK(m);
xx+=OK(s);
if(xx==0||xx==3)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
};
int main(){
Point s;
s.Set();
cin>>a>>b;
a%=12;
b%=12;
if(a>b){
swap(a,b);
}
a*=30.0,b*=30.0;
s.solve();
return 0;
}