Codeforces868b race against time

Posted by yjjr's blog on February 6, 2018

标签:模拟,平面几何

Have you ever tried to explain to thecoordinator, why it is eight hours to the contest and not a single problem hasbeen prepared yet? Misha had. And this time he has a really strong excuse: hefaced a space-time paradox! Space and time replaced each other.

The entire universe turned into an enormousclock face with three hands — hour, minute, and second. Time froze, andclocks now show the timeh hours, m minutes, s seconds.

Last time Misha talked with the coordinatoratt1 o'clock, so now he stands on the number t1on the clock face. The contest should be ready byt2 o'clock.In the terms of paradox it means that Misha has to go to numbert2somehow. Note that he doesn't have to move forward only: in these circumstancestime has no direction.

Clock hands are very long, and Misha cannotget round them. He also cannot step over as it leads to the collapse ofspace-time. That is, if hour clock points 12 and Misha stands at 11 then hecannot move to 1 along the top arc. He has to follow all the way round theclock 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 (orshould we say on space?). That is, find if he can move fromt1to 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 notcoincide 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 thepictures below from left to right. The starting position of Misha is shown withgreen, the ending position is shown with pink. Note that the positions of thehands on the pictures are not exact, but are close to the exact and the answeris the same.

 

题意:给定一个时刻,将其视为钟面,指针将其划分为许多区域,再读入两个时刻,问这两个时刻是否在同一个区域内

直接模拟就好了,注意下精度的问题

Code

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define mem(x,num) memset(x,num,sizeof x)
using namespace std;
double h,m,s,t1,t2;
bool first,second;
int main()
{
	first=second=true;
	cin>>h>>m>>s>>t1>>t2;
	if(h==12)h=0;
	if(t1==12)t1=0;
	if(t2==12)t2=0;
	h=h*30+m/60+s/3600;
	m=(m+s/60)*6;
	s=s*6;
	t1*=30,t2*=30;
	//cout<<h<<endl<<m<<endl<<s<<endl<<t1<<endl<<t2<<endl;
	if(t1>t2)swap(t1,t2); 
	if(h>t1&&h<t2)first=false;
	if(m>t1&&m<t2)first=false;
	if(s>t1&&s<t2)first=false;
	if(h>t2&&h<=360)second=false;
	if(m>t2&&m<=360)second=false;
	if(s>t2&&s<=360)second=false;
	if(h<t1&&h>=0)second=false;
	if(m<t1&&m>=0)second=false;
	if(s<t1&&m>=0)second=false;
	if(first||second)cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}




本文可以转载,但必须附上原文链接,否则你会终生找不到妹子!!!欢迎关注我的CSDN: ahyjjr