Codeforce Race Against Time
来源:互联网 发布:淘宝女运动套装大吗 编辑:程序博客网 时间:2024/06/03 10:09
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 areally 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 timeh hours, m minutes,s seconds.
Last time Misha talked with the coordinator at t1 o'clock, so now he stands on the numbert1 on the clock face. The contest should be ready byt2 o'clock. In the terms of paradox it means that Misha has to go to numbert2 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 sayon space?). That is, find if he can move fromt1 to t2 by the clock face.
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.
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").
12 30 45 3 11
NO
12 0 1 12 1
YES
3 47 0 4 9
YES
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<iostream>#include<cstdio>#include<cmath>#include<string>#include<algorithm>using namespace std;bool pd(double l,double r,double a,double b){ if( (a>=l&&a<=r) && (b>=l&&b<=r))return 1; return 0;}int main(){ double h,s,m,a,b; cin>>h>>s>>m>>a>>b; if(a>b)swap(a,b); if(s!=0 || m!=0) h+=0.1; s=s*1.0/60*12; if(m!=0) s+=0.1; m=m*1.0/60*12; double p[5]={h,s,m}; sort(p,p+3); int f=0; for(int i=0;i<2;i++) if(pd(p[i],p[i+1],a,b)) f=1; if( (a<=p[0]&&b>=p[2]) || (a>=p[2] && b>=p[2]) || (a<=p[0]&& b<=p[0])) f=1; cout<< (f==1?"YES":"NO") <<endl; return 0;}
- Codeforce Race Against Time
- Codeforces868B Race Against Time
- ACM刷题之codeforce————Race Against Time
- SPOJ 3261. Race Against Time(RACETIME)(分块)
- CF 868 B. Race Against Time【模拟】
- codeforces 868B Race Against Time
- Codeforces 868B. Race Against Time 模拟
- 【Codeforces 868 B. Race Against Time】& 模拟
- Codeforces Round #438 B. Race Against Time
- Codeforces868B Race Against Time (模拟)
- CodeForces 868B Race Against Time
- codeforces 868B Race Against Time
- SPOJ 3261. Race Against Time(RACETIME) 【线段树套SBT】
- Codeforces Round #438 B. Race Against Time 思路很重要
- Codeforces Round #438 (868B) B Race Against Time
- Codeforces 868 B Race Against Time(水题)
- CodeFroces Round 438 B.Race Against Time(模拟)
- Codeforces Round #438 B Race Against Time(模拟)
- 1.面向对象--类与对象体现 2.面向对象--成员变量和局部变量的区别 3.面向对象-类类型的变量 4.面向对象-引用,基本数据类型参数传递图解
- 1037: 递归7(走迷宫)
- 洛谷 3386 二分图匹配模板 匈牙利算法
- 后缀数组简介(洛谷P3809)
- Python2.x和Python3.x的区别
- Codeforce Race Against Time
- 用mock.js模拟地图经纬度数据
- ucosii关键点笔记
- 前端性能优化的方法
- HappyBase安装&Python操作HBase
- HTTP状态码大全
- 洛谷10月月赛R1·浴谷八连测R1·提高组 SAC E#1
- Machine learning
- 使用T-sql创建数据库