zoukankan      html  css  js  c++  java
  • codeforces 868B Race Against Time

    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").


    Example
    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<stdio.h>
    #include<iostream>
    #include<string.h>
    #include<algorithm>
    using namespace std;
    int t[100];
    int main()
    {
        int h,m,s,x,y;
        while(~scanf("%d%d%d%d%d",&h,&m,&s,&x,&y))
        {
            memset(t,0,sizeof(t));
            h*=5;
            h+=(m*(5.0/60));
            t[h%60]=1;
            t[m%60]=t[s%60]=1;
            x*=5;
            y*=5;
            x%=60;y%=60;
            int a=max(x,y);
            int b=min(x,y);
           // printf("a=%d b=%d
    ",a,b);
            int flag1=0,flag=0;
            for(int i=b; i<a; i++)
            {
                if(t[i%60]==1)
                {
                    //printf("i=%d
    ",i);
                    flag=1;
                    break;
                }
            }
            for(int i=a; i<(b+60); i++)
            {
                if(t[i%60]==1)
                {
                   // printf("i=%d
    ",i);
                    flag1=1;
                    break;
                }
            }
            if(flag==0||flag1==0)
                printf("YES
    ");
            else
                printf("NO
    ");
        }
    }
















  • 相关阅读:
    NSURLSession学习笔记(一)简介
    Objective-C的属性和成员变量用法及关系浅析
    Object-C 中的Selector 概念
    IOS SEL (@selector) 原理及使用总结(一)
    iOS应用截屏
    iOS运行时工具-cycript
    iOS设备是否越狱的判断代码
    iphone——日期处理
    在iOS中使用ZBar扫描二维码
    使用Dockerfile docker tomcat部署
  • 原文地址:https://www.cnblogs.com/da-mei/p/9053331.html
Copyright © 2011-2022 走看看