首页 技术 正文
技术 2022年11月18日
0 收藏 927 点赞 5,119 浏览 1624 个字

Description

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.

解题报告

直接把三个针用转成时钟上的位置,也就是值域为 \([0,12]\) ,double储存,然后分两种情况讨论即可,注意细节

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
double a[5];
void work()
{
double h,m,s,t1,t2;
cin>>h>>m>>s>>t1>>t2;
a[1]=h+m/60+s/3600;
if(a[1]>=12)a[1]-=12;
a[2]=m/5+s/300;
if(a[2]>=12)a[2]-=12;
a[3]=s/5;
if(a[3]>=12)a[3]-=12;
int i;
if(t1<t2)swap(t1,t2);
for(i=1;i<=3;i++){
if(t1<=a[i] && a[i]<=12)break;
if(0<=a[i] && a[i]<=t2)break;
}
if(i==4){
puts("YES");
return ;
}
for(i=1;i<=3;i++){
if(t2<=a[i] && a[i]<=t1)break;
}
if(i==4){
puts("YES");
return ;
}
puts("NO");
}int main()
{
work();
return 0;
}
上一篇: C++11---nullptr
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,076
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,552
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,400
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,176
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,812
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,894