ACM刷题之codeforce————Race Against Time

版权声明:本文为小时的枫原创文章,未经博主允许不得转载。 https://blog.csdn.net/xiaofeng187/article/details/78162565
 Race Against Time
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard 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 hmst1t2 (1 ≤ h ≤ 120 ≤ m, s ≤ 591 ≤ t1, t2 ≤ 12t1 ≠ 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>
using namespace std;
#define MID(x,y) ((x+y)>>1)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int N=2e5+7;

int main()
{
	//freopen("f:/input.txt", "r", stdin);
	double h,m,s,t1,t2,i,j,k,n;
	scanf("%lf%lf%lf%lf%lf",&h,&m,&s,&t1,&t2);
	if(h==12) {
		h=0;
	}
	if(t1 == 12){
		t1=0;
	} 
	if(t2 == 12){
		t2=0;
	}	
	h = h*30 + m/2 + s/120;
	m = m*6 + s/10;
	s = s*6;
	
	t1=30*t1;
	t2=30*t2;
	if(t1>t2) {
		int x = t1;
		t1 = t2;
		t2 = x;
	}
	if((h>t1&&h<t2) && (m>t1&&m<t2) && (s>t1&&s<t2)) {
		printf("YES\n");
		return 0;
	}else if((h<t1 ||h>t2) && (m<t1 || m>t2) && (s<t1 || s>t2)) {
		printf("YES\n");
		return 0;
	}else {
		printf("NO\n");
		return 0;
	}
}


扫描二维码关注公众号,回复: 5044221 查看本文章

猜你喜欢

转载自blog.csdn.net/xiaofeng187/article/details/78162565