HDU 1209

http://acm.hdu.edu.cn/showproblem.php?pid=1209

水题,按五个时针分针成的锐角从小到大排序,角度相同时间从早到晚,输出中间的那个

时针一小时走30度,一分钟走0.5度,分针一分钟走6度,注意是锐角,大于180要用360减回去,为避免精度出问题统一乘2拒绝小数

#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;

struct node {
    int hh, mm;
    int ang;
}kk[5];

int ABS(int x) {
    return x > 0 ? x : -x;
}

int cmp(node a, node b) {
    if(a.ang == b.ang) return a.hh * 60 + a.mm < b.hh * 60 + b.mm;
    return a.ang < b.ang;
}

int main() {
    int T;
    scanf("%d", &T);
    while(T--) {
        for(int i = 0; i < 5; i++) {
            scanf("%d:%d", &kk[i].hh, &kk[i].mm);
            kk[i].ang = ABS(kk[i].hh % 12 * 60 + kk[i].mm - kk[i].mm * 12);
             if(kk[i].ang > 360) kk[i].ang = 720 - kk[i].ang;
        }
        sort(kk, kk + 5, cmp);
        printf("%02d:%02d\n", kk[2].hh, kk[2].mm);
    }
    return 0;
}

时间: 2024-10-26 01:48:43

HDU 1209的相关文章

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 Problem Description There is an analog clock with two hands: an hour hand and a minute hand. The two ha

杭电 HDU 1209 Clock

Clock Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5140    Accepted Submission(s): 1589 Problem Description There is an analog clock with two hands: an hour hand and a minute hand. The two h

hdu 1209 Clock(排序)

题意:按钟表的时针.分针的夹角对5个时间进行升序排序,输出第3个时间 思路:排序 注意:若夹角相同,则按时间进行升序排序 #include<iostream> #include<stdio.h> #include<algorithm> using namespace std; struct node{ int ti[2]; double ang; }a[5]; int cmp(node a,node b){ if(a.ang!=b.ang)return a.ang<

hrbust 1209/hdu 4099 Revenge of Fibonacci【字典树+大数】

Revenge of Fibonacci Time Limit: 5000 MS Memory Limit: 204800 K Total Submit: 37(24 users) Total Accepted: 18(17 users) Rating:  Special Judge: No Description The well-known Fibonacci sequence is defined as following: F(0) = F(1) = 1 F(n) = F(n - 1)

HDU分类

模拟题, 枚举 1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 1106 1107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 1197 1200 1201 12

HDU 3853 LOOPS (概率dp)

LOOPS Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 125536/65536 K (Java/Others) Total Submission(s): 2931    Accepted Submission(s): 1209 Problem Description Akemi Homura is a Mahou Shoujo (Puella Magi/Magical Girl). Homura wants to help

转载:hdu 题目分类 (侵删)

转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029. 1032.1037.1040.1048.1056.1058.1061.1070.1076.1089.1090.1091.1092.1093. 1094.1095.1096.1097.1098.1106.1108.1157.116

HDU——PKU题目分类

HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 1106 1107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 1197 1200 1201

HDU 6203 ping ping ping [LCA,贪心,DFS序,BIT(树状数组)]

题目链接:[http://acm.hdu.edu.cn/showproblem.php?pid=6203] 题意 :给出一棵树,如果(a,b)路径上有坏点,那么(a,b)之间不联通,给出一些不联通的点对,然后判断最少有多少个坏点. 题解 :求每个点对的LCA,然后根据LCA的深度排序.从LCA最深的点对开始,如果a或者b点已经有点被标记了,那么continue,否者标记(a,b)LCA的子树每个顶点加1. #include<Bits/stdc++.h> using namespace std;