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°,那么每 ...
随机推荐
- 测试使用API
https://api.github.com/users/github 返回值中的某些URL也可以作为测试API使用
- 使用druid连接池的超时回收机制排查连接泄露
起因:系统连接池满了 Exception wait millis 60012, active 2000, maxActive 2000, creating 0 加配置排查: <!-- 超过时间限 ...
- myeclipse关掉references
去掉下面两个勾选:
- leetcode解题报告(17):Missing Number
描述 Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is mis ...
- 【csp模拟赛九】--dfs3
这道题贪心错误:直接dfs就行,枚举新开一个还是往之前的里面塞 贪心代码(80): #include<cstdio> #include<algorithm> #include& ...
- P2313 [HNOI2005]汤姆的游戏
题目描述 汤姆是个好动的孩子,今天他突然对圆规和直尺来了兴趣.于是他开始在一张很大很大的白纸上画很多很多的矩形和圆.画着画着,一不小心将他的爆米花弄撒了,于是白纸上就多了好多好多的爆米花.汤姆发现爆米 ...
- (WAWAWAWAWAWAW) G. Periodic RMQ Problem
没有联通门 : Codeforces G. Periodic RMQ Problem /* Codeforces G. Periodic RMQ Problem MMP 什么动态开点线段树啊 ... ...
- jQuery多选和单选下拉框插件select.js
一.插件描述 可通过参数设置多选或者单选,多选返回数组结果,单选返回字符串,如图: 下载地址:https://pan.baidu.com/s/1JjVoK89_ueVVpfSlMDJwUQ 提取码 ...
- 判断List<E>内是否有重复对象
主要用到Java 8的Stream类 long distinctedSize = list.stream().distinct().count(); boolean hasRepeat = list. ...
- 小程序wx.showLoading的使用
比如说在用户点击登录的时候,为了防止用户点击点第二次,可以加一个loading,在请求结束之后就关闭