zoukankan      html  css  js  c++  java
  • Codeforces 868B 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 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.


      题目大意 给定一个时刻,在给定两个整点,问它们是否被划分到了同一块。

      直接计算就好了。。

      不知道昨天四个同学打这场比赛,为什么全挂B题了。。我回家写,1a。。。

    Code

     1 /**
     2  * Codeforces
     3  * Problem#868B
     4  * Accepted
     5  * Time: 15ms
     6  * Memory: 0k
     7  */
     8 #include <bits/stdc++.h>
     9 using namespace std;
    10 
    11 // 1 Tick = 1 / 720 Small Block 
    12 
    13 int arr[3];
    14 int t1, t2;
    15 
    16 inline void init() {
    17     for(int i = 0; i < 3; i++)
    18         scanf("%d", arr + i);
    19     scanf("%d%d", &t1, &t2);
    20 //    (arr[0] = arr[0] * 3600 + arr[1] * 60 + arr[2]) %= 43200;
    21 //    (arr[1] = arr[1] * 720 + arr[2] * 12) %= 43200;
    22     arr[0] = arr[0] * 3600 + arr[1] * 60 + arr[2];
    23     arr[1] = arr[1] * 720 + arr[2] * 12;
    24     arr[2] = arr[2] * 720;
    25     t1 *= 3600, t2 *= 3600;
    26 }
    27 
    28 inline int getPart(int t) {
    29     if(t >= arr[0] && t < arr[1])    return 1;
    30     if(t >= arr[1] && t < arr[2])    return 2;
    31     return 3;    
    32 }
    33 
    34 inline void solve() {
    35     sort(arr, arr + 3);
    36     puts((getPart(t1) == getPart(t2)) ? ("YES") : ("NO"));
    37 }
    38 
    39 int main() {
    40     init();
    41     solve();
    42     return 0;
    43 }
  • 相关阅读:
    对 String 的几个错误认识 X
    用C# 自定义Window7的JumpList(跳转列表) X
    IPv6无状态自动配置功能配合DHCPv6无状态配置功能 实现IPv6自动分配
    H3C S7500E IPV6白皮书
    静默方式执行chkdsk命令
    IPv6基本知识(转载)
    解决win7官方主题themepack无法安装的问题
    英保通等PXE网刻软件的使用
    通过命令提示符修改windows默认打印机
    OFFICE2010出现两个激活信息的处理办法。
  • 原文地址:https://www.cnblogs.com/yyf0309/p/7632528.html
Copyright © 2011-2022 走看看