Codeforces868B Race Against Time
来源:互联网 发布:德州力拓软件 编辑:程序博客网 时间:2024/06/06 00:03
标签:模拟,平面几何
Have you ever tried to explain to thecoordinator, why it is eight hours to the contest and not a single problem hasbeen prepared yet? Misha had. And this time he has a really strong excuse: hefaced a space-time paradox! Space and time replaced each other.
The entire universe turned into an enormousclock face with three hands — hour, minute, and second. Time froze, andclocks now show the timeh hours, m minutes, s seconds.
Last time Misha talked with the coordinatoratt1 o'clock, so now he stands on the number t1on the clock face. The contest should be ready byt2 o'clock.In the terms of paradox it means that Misha has to go to numbert2somehow. Note that he doesn't have to move forward only: in these circumstancestime has no direction.
Clock hands are very long, and Misha cannotget round them. He also cannot step over as it leads to the collapse ofspace-time. That is, if hour clock points 12 and Misha stands at 11 then hecannot move to 1 along the top arc. He has to follow all the way round theclock 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 (orshould we say on space?). That is, find if he can move fromt1to 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 notcoincide 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 thepictures below from left to right. The starting position of Misha is shown withgreen, the ending position is shown with pink. Note that the positions of thehands on the pictures are not exact, but are close to the exact and the answeris the same.
题意:给定一个时刻,将其视为钟面,指针将其划分为许多区域,再读入两个时刻,问这两个时刻是否在同一个区域内
直接模拟就好了,注意下精度的问题
Code
#include<bits/stdc++.h>#define rep(i,a,b) for(int i=a;i<=b;i++)#define dep(i,a,b) for(int i=a;i>=b;i--)#define mem(x,num) memset(x,num,sizeof x)using namespace std;double h,m,s,t1,t2;bool first,second;int main(){first=second=true;cin>>h>>m>>s>>t1>>t2;if(h==12)h=0;if(t1==12)t1=0;if(t2==12)t2=0;h=h*30+m/60+s/3600;m=(m+s/60)*6;s=s*6;t1*=30,t2*=30;//cout<<h<<endl<<m<<endl<<s<<endl<<t1<<endl<<t2<<endl;if(t1>t2)swap(t1,t2); if(h>t1&&h<t2)first=false;if(m>t1&&m<t2)first=false;if(s>t1&&s<t2)first=false;if(h>t2&&h<=360)second=false;if(m>t2&&m<=360)second=false;if(s>t2&&s<=360)second=false;if(h<t1&&h>=0)second=false;if(m<t1&&m>=0)second=false;if(s<t1&&m>=0)second=false;if(first||second)cout<<"YES\n";else cout<<"NO\n";return 0;}
- Codeforces868B Race Against Time
- Codeforces868B Race Against Time (模拟)
- 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
- 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(模拟)
- Codeforces Round #438 B. Race Against Time 题解
- PL/SQL
- HDU 5970 最大公约数(找规律)
- Android View框架的measure机制
- C语言基础知识学习(数组)
- MySQL与eclipse建立连接
- Codeforces868B Race Against Time
- 一对多双向关联 、 多对一
- ios-collectionView?.deleteItems(at: [indexPath])造成的错误
- (M)Dynamic Programming: 474. Ones and Zeroes
- SylixOS 系统TICK实现
- js与jquery知识点总结(1)
- Plant CodeForces
- SSL2759 2017年10月6日提高组T2 挖矿(dp)
- 多线程之锁机制