关闭

HDU 5387 Clock(简单模拟)——2015 Multi-University Training Contest 8

标签: 模拟
522人阅读 评论(0) 收藏 举报
分类:

传送门

Clock

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1178    Accepted Submission(s): 671


Problem Description
Give a time.(hh:mm:ss),you should answer the angle between any two of the minute.hour.second hand
Notice that the answer must be not more 180 and not less than 0
 

Input
There are T(1T104) test cases
for each case,one line include the time

0hh<24,
0mm<60,0ss<60
 

Output
for each case,output there real number like A/B.(A and B are coprime).if it’s an integer then just print it.describe the angle between hour and minute,hour and second hand,minute and second hand.
 

Sample Input
4
00:00:00
06:00:00
12:54:55
04:40:00
 

Sample Output
0 0 0
180 180 0
1391/24 1379/24 1/2
100 140 120

Hint
每行输出数据末尾均应带有空格
 

Author
SXYZ
 

Source

题目大意:

给你一个 24 小时的时刻,时:分:秒,让你求时针与分针、时针和秒针以及分针和秒针的角度(取 180)。

解题思路:

这个题目就是一个模拟,我们将其全部换算为一个单位上也就是 时针一秒走多少角度,分针一秒走多少角度,把这个求出来之后:

秒针: 1 秒走 6°

分针: 1 秒走 110°

时针: 1 秒走 1120°

因为带有分数, 所以我们将其分子分母同乘以 120 得到的是整数,然后进行一系列的操作就行了,还有就是 12hh 的将其化为 0  11

之间的数就 OK ,最后在除以 120ans 的最大公约数就行了。

My Code

/**
2016 - 08 - 31 下午
Author: ITAK

Motto:

今日的我要超越昨日的我,明日的我要胜过今日的我,
以创作出更好的代码为目标,不断地超越自己。
**/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF = 1e9+5;
const int MAXN = 1e6+5;
const int MOD = 1e9+7;
const double eps = 1e-7;
const double PI = acos(-1);
using namespace std;
LL Scan_LL()///输入外挂
{
    LL res=0,ch,flag=0;
    if((ch=getchar())=='-')
        flag=1;
    else if(ch>='0'&&ch<='9')
        res=ch-'0';
    while((ch=getchar())>='0'&&ch<='9')
        res=res*10+ch-'0';
    return flag?-res:res;
}
int Scan_Int()///输入外挂
{
    int res=0,ch,flag=0;
    if((ch=getchar())=='-')
        flag=1;
    else if(ch>='0'&&ch<='9')
        res=ch-'0';
    while((ch=getchar())>='0'&&ch<='9')
        res=res*10+ch-'0';
    return flag?-res:res;
}
void Out(LL a)///输出外挂
{
    if(a>9)
        Out(a/10);
    putchar(a%10+'0');
}
inline int GCD(int a, int b)
{
    if(b == 0)
        return a;
    return GCD(b, a%b);
}
int main()
{
    int T, h, m, s, all = 360*120;
    cin>>T;
    while(T--)
    {
        scanf("%d:%d:%d",&h,&m,&s);
        if(h >= 12)
            h -= 12;
        h = h*3600 + m*60 + s;
        m = m*60 + s;
        s = s*6;
        m = m*12;
        s = s*120;
        int hm = abs(h-m);
        int hs = abs(h-s);
        int ms = abs(m-s);
        hm = min(all-hm, hm);
        hs = min(all-hs, hs);
        ms = min(all-ms, ms);
        int hm1 = GCD(hm, 120);
        int hs1 = GCD(hs, 120);
        int ms1 = GCD(ms, 120);
        if(hm1 != 120)
            printf("%d/%d ",hm/hm1,120/hm1);
        else
            printf("%d ",hm/hm1);
        if(hs1 != 120)
            printf("%d/%d ",hs/hs1,120/hs1);
        else
            printf("%d ",hs/hs1);
        if(ms1 != 120)
            printf("%d/%d \n",ms/ms1,120/ms1);
        else
            printf("%d \n",ms/ms1);
    }
    return 0;
}
0
0
查看评论

Hdu 2015 Multi-University Training Contest8

Hdu 2015 多校
  • u013508213
  • u013508213
  • 2015-08-14 20:07
  • 389

2015 Multi-University Training Contest 8(HDOJ5384、5389)

官方题解:http://bestcoder.hdu.edu.cn/blog/ HDOJ5387超过600人AC,思路见官方题解 HDOJ5384虽然AC人数超过300人,306人AC,但是本弱比赛时TLE没出来,于是还是写写题解。。。 HDOJ5384 题意:...
  • bnmjmz
  • bnmjmz
  • 2015-08-17 17:12
  • 498

2014 Multi-University Training Contest 解题报告

多校比赛解题报告: 2014 Multi-University Training Contest 8:多校第八场 2014 Multi-University Training Contest 7:多校第七场 2014 Multi-University Training Contest 6:多校第...
  • u011466175
  • u011466175
  • 2014-08-16 11:42
  • 930

2016 Multi-University Training Contest 8(2016多校训练第八场)1011

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5831 题目大意:给定一个由左右括号构成的字符序列,如果所有的左括号都能有一个右括号与之对应,则认为该序列是“正确的”,现在给出若干这样的序列,当然它们有可能是正确的,也有可能是不正确的,问,是否能...
  • Runner__1
  • Runner__1
  • 2016-08-11 21:06
  • 520

HDU 3602 2012(2010 ACM-ICPC Multi-University Training Contest(16)——Host by NUDT)

//dp[i]表示挣i块钱最少需要的座位数 //01背包的思想,大家可以这样想,对于每个船我们可选可不选,那么这样 //很明显就是一个01背包了。 #include <cstdio> #include <cstring> #include <iostream> #...
  • chen_ze_hua
  • chen_ze_hua
  • 2016-09-14 10:54
  • 181

HDU 6069 Counting Divisors(素数筛法+枚举+技巧)——2017 Multi-University Training Contest - Team 4

传送门 Counting DivisorsTime Limit: 10000/5000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 7...
  • qingshui23
  • qingshui23
  • 2017-08-03 20:34
  • 1236

Tree //2010 ACM-ICPC Multi-University Training Contest(10)——Host by HEU

Tree Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)Total Submission(s) : 17   Accepted...
  • hqd_acm
  • hqd_acm
  • 2010-08-29 19:23
  • 733

HDU 3605 Escape 最大流or二分图多重匹配 2010 ACM-ICPC Multi-University Training Contest(17)——Host by ZSTU

Escape Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1122 Accepted Submission(s):
  • power721
  • power721
  • 2011-09-10 09:43
  • 1552

2017 Multi-University Training Contest - 第一场 04 Division Game (NTT+数学)

题目链接: HDU 6036题解: (官方:题解)显然每个石子堆最多做 ∑ m i=1 e i  \sum_{i = 1}^{m}{e_i} (记为 w w )次操作。此外,如果定义一个堆做 x x 次操作恰好变为 ...
  • liangzhaoyang1
  • liangzhaoyang1
  • 2017-07-26 10:33
  • 490

2016 Multi-University Training Contest 9题解报告

2016 Multi-University Training Contest 9题解报告
  • queuelovestack
  • queuelovestack
  • 2016-08-16 17:04
  • 1233
    个人资料
    • 访问:528708次
    • 积分:11547
    • 等级:
    • 排名:第1588名
    • 原创:639篇
    • 转载:5篇
    • 译文:0篇
    • 评论:93条
    博客专栏