cf_438_B

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/LSC_333/article/details/78164884

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.

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

题意:

先给出时分秒,然后给出t1,t2,如果在钟面上能够从t1走到t2却不经过任何指针,就输出YES,否则输出NO


思路:

不能走到的情况是在t1和t2这两点组成的优弧和劣弧上都有指针,那么直接这样判断就行,只要注意把分和秒处理下就行


#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <stack>
#define INF 0x3f3f3f3f
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
int t[3];
int t1, t2;
int main()
{
    while(~scanf("%d%d%d%d%d", &t[0], &t[1], &t[2], &t1, &t2))
    {
        t[1]/=5;
        t[2]/=5;
        if(t1>t2)
        {
            int kk=t1;
            t1=t2;
            t2=kk;
        }
        bool flag1=false;
        bool flag2=false;
        for(int i=0; i<3; i++)
            if((t[i]>=t1)&&(t[i]<t2))
                flag1=true;
        for(int i=0; i<3; i++)
            if((t[i]<t1)||(t[i]>=t2))
                flag2=true;
        if(flag1&&flag2)
            printf("NO\n");
        else
            printf("Yes\n");
    }
    return 0;
}



猜你喜欢

转载自blog.csdn.net/LSC_333/article/details/78164884