hdu 1209 Clock
Clock
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5870 Accepted Submission(s):
1872
and a minute hand. The two hands form an angle. The angle is measured as the
smallest angle between the two hands. The angle between the two hands has a
measure that is greater than or equal to 0 and less than or equal to 180
degrees.
Given a sequence of five distinct times written in the format hh
: mm , where hh are two digits representing full hours (00 <= hh <= 23)
and mm are two digits representing minutes (00 <= mm <= 59) , you are to
write a program that finds the median, that is, the third element of the sorted
sequence of times in a nondecreasing order of their associated angles. Ties are
broken in such a way that an earlier time precedes a later time.
For
example, suppose you are given a sequence (06:05, 07:10, 03:00, 21:00, 12:55) of
times. Because the sorted sequence is (12:55, 03:00, 21:00, 06:05, 07:10), you
are to report 21:00.
cases (T) is given on the first line of the input file. Each test case is given
on a single line, which contains a sequence of five distinct times, where times
are given in the format hh : mm and are separated by a single space.
to contain the median in the format hh : mm of the times given. The following
shows sample input and output for three test cases.
#include <stdlib.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define N 1000
struct SS
{
int hh,mm;
double r;
}f[N];
int cmp(SS a,SS b)
{
if(a.r!=b.r)
return a.r<b.r;
if(a.r==b.r&&a.hh!=b.hh)
return a.hh<b.hh;
}
int main()
{ //freopen("1.txt","r",stdin);
int i,test,m,n;
cin>>test;
while(test--)
{
for(i=0;i<5;i++)
scanf("%d:%d",&f[i].hh,&f[i].mm);
for(i=0;i<5;i++)
{
if(f[i].hh>12)
{
f[i].r=fabs(30.0*(f[i].hh-12)+f[i].mm/2.0-6.0*f[i].mm);
}
else
{
f[i].r=fabs(30.0*f[i].hh+f[i].mm/2.0-6.0*f[i].mm);
}
if(f[i].r>180)
f[i].r=360-f[i].r;
}
sort(f,f+5,cmp);
printf("%02d:%02d\n",f[2].hh,f[2].mm);
}
return 0;
}
hdu 1209 Clock的更多相关文章
- hdu 1209 Clock(排序)
题意:按钟表的时针.分针的夹角对5个时间进行升序排序,输出第3个时间 思路:排序 注意:若夹角相同,则按时间进行升序排序 #include<iostream> #include<st ...
- HDU 1209
http://acm.hdu.edu.cn/showproblem.php?pid=1209 水题,按五个时针分针成的锐角从小到大排序,角度相同时间从早到晚,输出中间的那个 时针一小时走30度,一分钟 ...
- HDU 5705 Clock(模拟,分类讨论)
Clock Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submi ...
- HDU——1393Weird Clock(水题,注意题意)
Weird Clock Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- HDU 5705 Clock (精度控制,暴力)
题意:给定一个开始时间和一个角度,问你下一个时刻时针和分针形成这个角度是几点. 析:反正数量很小,就可以考虑暴力了,从第一秒开始暴力,直到那个角度即可,不会超时的,数目很少,不过要注意精度. 代码如下 ...
- HDU 5387 Clock
题意:给一个时间,求三个时针之间的夹角,分数表示. 解法:算算算.统一了一下分母. 代码: #include<stdio.h> #include<iostream> #incl ...
- HDU 5387 Clock (MUT#8 模拟)
[题目链接]:pid=5387">click here~~ [题目大意]给定一个时间点.求时针和分针夹角,时针和秒针夹角,分针和秒针夹角 模拟题,注意细节 代码: #include&l ...
- HDU 5387 Clock(分数类+模拟)
题意: 给你一个格式为hh:mm:ss的时间,问:该时间时针与分针.时针与秒针.分针与秒针之间夹角的度数是多少. 若夹角度数不是整数,则输出最简分数形式A/B,即A与B互质. 解析: 先计算出总的秒数 ...
- HDU 5705 Clock(2016杭电女生专场1004)——角度追及问题
题意是给出一个当前的时间和角度a,问从现在开始的下一个时针和分针形成角度a的时间是多少,时间向下取整. 分析:时针3600s走30°,故120s走1°,分针3600s走360°,故10s走1°,那么每 ...
随机推荐
- linux 搭建elk6.8.0集群并破解安装x-pack
一.环境信息以及安装前准备 1.组件介绍 *Filebeat是一个日志文件托运工具,在你的服务器上安装客户端后,filebeat会监控日志目录或者指定的日志文件,追踪读取这些文件(追踪文件的变化,不停 ...
- 数据结构实验之二叉树一:树的同构 (SDUT 3340)
题解:把原本结构体的左右子树的类型定义成 int 型,用来存放这个结点的左右子树的编号,分别建造两棵二叉树,按个比较,如果在第二棵树中没有找到,那么就不用在判断了. #include <bits ...
- Vue自定义日历组件
今天给大家介绍Vue的日历组件,可自定义样式.日历类型及支持扩展,可自定义事件回调.Props数据传输. 线上demo效果 示例 Template: <Calendar :sundayStart ...
- 记录一次腾讯X5内核64位手机初始化失败
之前一直在使用x5内核,只需要一个jar包和so文件就能让webview实现多余原生webview的水平,在32位的手机上能够正常运行,但是到了64位手机上就报如下错误: E/ERROR:: .... ...
- linux pip install gdal apyt-get install libgdal-dev export cplus_path=/usr/include/gdal export c_path=/usr/include/gdal
apt-get install libgdal-dev pip install gdal
- JMeter_控制器执行效果_给自己挖过的坑
线程及循环设置: 数据文件中放在“循环控制器”中的执行效果:每条数据执行5次,取够50条数据时停止 简单逻辑控制器按下面的目录创建后,执行结果效果同上面循环控制器的执行效果 本来想规整下目录结构,结果 ...
- opencv 检测人脸、人眼
This tutorial code’s is shown lines below. You can also download it from here . The second version ( ...
- jeecg使用心得
接触到jeecg框架是在去年,接触到了jeecg开源框架,此框架为企业级急速开发框架,不了解的可以百度下这类框架的,对于目前状态来说,此框架确实也满足了所需,此刻就开始接触jeecg框架,去年六七月份 ...
- Facebook libra开发者文档- 1 -welcome
参考https://developers.libra.org/docs/welcome-to-libra 欢迎来到Libra开发者网站!Libra的使命是建立一个简单的全球货币和金融基础设施,为数十亿 ...
- log4j.xml简单配置实现在控制台打印sql执行语句【加注释】
转: log4j.xml简单配置实现在控制台打印sql执行语句 2017年09月27日 13:02:34 艾然丶 阅读数 8804 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协 ...