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;}
- codeforce_868B_模拟水
- 水模拟
- POJ 1565 水 模拟
- poj2572 水模拟
- hdu4772 水模拟
- 模拟水题。。。
- HDU 3682 水模拟
- BZOJ 1088 水模拟
- 4452 模拟水题
- hdu 4561 水模拟
- hdu_1049_水_模拟
- UVALive 4723 水模拟
- poj3087(模拟水题)
- hdu5319 模拟水题
- 模拟水的方法
- UVALive 6833 (模拟 水~)
- POJ1028 模拟,水
- HDU 5373 (模拟 水~)
- 为什么有了抽象类还要用接口呢?
- Android如何通过手机获取验证码来完成注册功能_Android
- 个人拥有的第一个博客,我是一个菜鸟前端程序员,希望有大神指导
- yum 安装nginx 后 nginx的 目录
- 快速幂
- codeforce_868B_模拟水
- ZigZag Conversion:把字符串改写成Z字排列
- 延迟hover事件
- bzoj1774 USACO 2009 Dec Gold 2.Cow Toll Paths 过路费 翻译+题解
- [NOIP2013]表达式求值 T2 模拟
- Oracle中分号提示无效字符的问题
- windows下matplotlib图例中文无法显示的解决办法
- Java 创建对象的几种方法
- Kubernetes安装和使用