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.
题目大意:
给定一个时间,在不经过时分秒针的情况下,从第t1点到t2点
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.
模拟,但有细节
算出double类型的详细时间,把针所指的都统一成60格一周的单位,即把小时×5
再把查询统一
接下来破环成链,模拟判断就行了
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
double h,m,s,t1,t2,h2,m2,s2;
int flag1,flag2;
int main()
{
cin>>h>>m>>s>>t1>>t2;
t1*=5.0;t2*=5.0;
m=m+s/;
if (m>=60.0) m-=60.0;
h=h*+m/;
if (h>=60.0) h-=60.0;
s2=60.0+s;
m2=60.0+m;
h2=60.0+h;
if (t1>t2) swap(t1,t2);
flag1=;
if ((t1<s&&s<t2)||(t1<s2&&s2<t2)||(t1<m&&m<t2)||(t1<m2&&m2<t2)||(t1<h&&h<t2)||(t1<h2&&h2<t2))
{
flag1=;
}
t1+=;
if (t1>t2) swap(t1,t2);
flag2=;
if ((t1<s&&s<t2)||(t1<s2&&s2<t2)||(t1<m&&m<t2)||(t1<m2&&m2<t2)||(t1<h&&h<t2)||(t1<h2&&h2<t2))
{
flag2=;
}
if (flag1||flag2) cout<<"YES\n";
else cout<<"NO\n";
}
codeforces 868B Race Against Time的更多相关文章
- codeforces 868B
B. Race Against Time time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- codeforces 868B The Eternal Immortality【暴力+trick】
B. The Eternal Immortality time limit per test 1 second memory limit per test 256 megabytes input st ...
- Codeforces Round #131 (Div. 2) E. Relay Race dp
题目链接: http://codeforces.com/problemset/problem/214/E Relay Race time limit per test4 secondsmemory l ...
- Codeforces Round #328 (Div. 2) C. The Big Race 数学.lcm
C. The Big Race Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/592/probl ...
- Codeforces Round #346 (Div. 2) D Bicycle Race
D. Bicycle Race 题目链接http://codeforces.com/contest/659/problem/D Description Maria participates in a ...
- Codeforces Round #346 (Div. 2) D. Bicycle Race 叉积
D. Bicycle Race 题目连接: http://www.codeforces.com/contest/659/problem/D Description Maria participates ...
- CodeForces 659D Bicycle Race (判断点是否为危险点)
D - Bicycle Race Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u S ...
- codeforces 659D D. Bicycle Race(水题)
题目链接: D. Bicycle Race time limit per test 1 second memory limit per test 256 megabytes input standar ...
- Codeforces 659D Bicycle Race【计算几何】
题目链接: http://codeforces.com/contest/659/problem/D 题意: 若干条直线围城的湖,给定直线的端点,判断多少个转点会有危险?(危险是指直走的的话会掉进水里) ...
随机推荐
- 学号:201621123032 《Java程序设计》第13周学习总结
1:本周学习总结 2:为你的系统增加网络功能(购物车.图书馆管理.斗地主等)-分组完成 2.1:简述你想为你的系统增加什么网络功能?设计思路是什么? 创建了一个服务器监听8080端口,通过网络助手客户 ...
- LOW版统计词频
import string path = 'waldnn' with open(path,'r') as text: words = [raw_word.strip(string.punctuatio ...
- RESTful三问
我觉得学习一个技术,其实就是要弄明白三件事情:是什么(what),为什么(why),怎么用(how).正是所谓的三W方法. 所以打算总结一个"三问"系列.为了自己学习,也分享给别人 ...
- JAVA_SE基础——44.抽象类的练习
抽象类要注意的细节: 1. 如果一个函数没有方法体,那么该函数必须要使用abstract修饰,把该函数修饰成抽象 的函数..2. 如果一个类出现了抽象的函数,那么该类也必须 使用abstract修饰. ...
- Spring知识点回顾(06)Profile 和 条件注解 @Conditional
1.设定环境中的active profiles 如:DispatcherServerlet的init-param spring.profiles.active=production spring.pr ...
- T410升级笔记
T410 win7 旗舰版 32 sp1 三星 DDR3 1066 mhz core i5 M 540 2.53GHZ 双核 日立 HTS725032A9A364 320G/7200转/分 sa ...
- LDAP apacheds解决方案
Apache DS 配置与管理 LADP基本介绍 LDAP(轻量级目录访问协议)以目录的形式来管理资源(域用户,用户组,地址簿,邮件用户,打印机等等). 特点: 1. LDAP是一种网略协议而 ...
- bootstrap 一个简单的登陆页面
效果如图:用bootstrap 写的一个简单的登陆 一.修改样式 样式可以自己调整,例如换个背景色之类的,修改 background-color属性就可以 #from { background-col ...
- Mac里安装Jmeter
前提是需要安装jdk,参见http://www.cnblogs.com/fun0623/p/4703456.html 1.解压包 (双击apache-jmeter-2.13) 2.进去到解压后的bin ...
- spring cloud zipkin sleuth与spring boot aop结合后,启动慢
问题描述: 引入了spring cloud的监控starter,间接引入jooq. 又引入了 spring-boot-starter-web,所以间接引入aop. 参考下面资料后:https://gi ...