codeforce_868B_模拟水

来源:互联网 发布:ios与安卓的区别 知乎 编辑:程序博客网 时间:2024/05/19 19:33

B. 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.

题意: 给你一个时间 ,然后你就会得到表盘上被表针划分的区间,
给你两个时针的位置,再同一区间就是YES other NO;
解:
直接模拟

#include<bits/stdc++.h>using namespace std;int main(){    double  h,m,s,i,j,t1,t2,a[22];    while(cin>>h>>m>>s>>t1>>t2)    {        m+=s/60;        h+=m/60;        if(h>12)        {            h=m/60;        }//      cout<<h<<" "<<m<<" "<<s<<endl;        a[0]=h,a[1]=12*(m/60),a[2]=12*(s/60);    //  printf("%lf\n",a[1]);        sort(a,a+3);    //printf("%lf %lf %lf\n",a[0],a[1],a[2]);        int f1=0,f2=0;        if(t1>a[0]&&t1<a[1]) f1=1;        else if(t1>a[1]&&t1<a[2]) f1=2;        if(t2>a[0]&&t2<a[1]) f2=1;        else if(t2>a[1]&&t2<a[2]) f2=2;    //  cout<<f1<<" "<<f2<<endl;        if(f1==f2) puts("YES");        else puts("NO");    }    return 0;}
原创粉丝点击