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$$(1\leq T \leq 10^4)$ test cases 
for each case,one line include the time

$0\leq hh<24$,$0\leq mm<60$,$0\leq ss<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

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

题意:

求给定时间点的时针、分针、秒针的夹角(分数、角度制)

分析:

tol=总秒数,时针1/120 °/s,分针1/10 °/s,秒针 6 °/s,

分针和时针转过的角度差(tol/10-tol/120)=11*tol/120;

秒针和时针转过的角度差(6*tol-tol/120)=719*tol/120;

秒针和分针转过的角度差(6*tol-tol/10)=59*tol/10;

然后前两个角度差的分子%(120*360)即%43200,后面一个%3600,这样就<360了,就是我们要求的夹角或其补角了。

然后判断夹角up/down 是否大于180度,刚开始我让它>180就360减去它,但是 这里是整除,也就是180多一点点的整除了变成180,所以要写成>=180或>179时就让360减去它。

接下来约分输出。

代码:

 #include<stdio.h>
int t,h,m,s,tol,up[],down[],g;
int gcd(int a,int b)
{return b?gcd(b,a%b):a;}
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d:%d:%d",&h,&m,&s);
tol=h*+m*+s;
up[]=(*tol)%();
up[]=(*tol)%();
up[]=(*tol)%();
down[]=down[]=;down[]=;
for(int i=; i<; i++)
{
g=gcd(up[i],down[i]);
up[i]/=g;down[i]/=g;
if(up[i]/down[i]>)up[i]=down[i]*-up[i];
if(down[i]==)printf("%d ",up[i]);
else printf("%d/%d ",up[i],down[i]);
}
printf("\n");
}
return ;
}

【HDU 5387】Clock的更多相关文章

  1. 【数位dp】【HDU 3555】【HDU 2089】数位DP入门题

    [HDU  3555]原题直通车: 代码: // 31MS 900K 909 B G++ #include<iostream> #include<cstdio> #includ ...

  2. 【HDU 5647】DZY Loves Connecting(树DP)

    pid=5647">[HDU 5647]DZY Loves Connecting(树DP) DZY Loves Connecting Time Limit: 4000/2000 MS ...

  3. -【线性基】【BZOJ 2460】【BZOJ 2115】【HDU 3949】

    [把三道我做过的线性基题目放在一起总结一下,代码都挺简单,主要就是贪心思想和异或的高斯消元] [然后把网上的讲解归纳一下] 1.线性基: 若干数的线性基是一组数a1,a2,a3...an,其中ax的最 ...

  4. 【HDU 2196】 Computer(树的直径)

    [HDU 2196] Computer(树的直径) 题链http://acm.hdu.edu.cn/showproblem.php?pid=2196 这题可以用树形DP解决,自然也可以用最直观的方法解 ...

  5. 【HDU 2196】 Computer (树形DP)

    [HDU 2196] Computer 题链http://acm.hdu.edu.cn/showproblem.php?pid=2196 刘汝佳<算法竞赛入门经典>P282页留下了这个问题 ...

  6. 【HDU 5145】 NPY and girls(组合+莫队)

    pid=5145">[HDU 5145] NPY and girls(组合+莫队) NPY and girls Time Limit: 8000/4000 MS (Java/Other ...

  7. 【hdu 1043】Eight

    [题目链接]:http://acm.hdu.edu.cn/showproblem.php?pid=1043 [题意] 会给你很多组数据; 让你输出这组数据到目标状态的具体步骤; [题解] 从12345 ...

  8. 【hdu 2108】Shape of HDU

    [题目链接]:http://acm.hdu.edu.cn/showproblem.php?pid=2108 [题意] [题解] 逆时针; 可以想象一下; 如果是凸多边形的话; 逆时针的相邻的两条边; ...

  9. 【hdu 2036】改革春风吹满地

    [题目链接]:http://acm.hdu.edu.cn/showproblem.php?pid=2036 [题意] 中文题 [题解] 这里用的是叉积对应的求三角形的面积; 即 A×B=A*B*sin ...

随机推荐

  1. 怎样在python中获取时间?

    from time import strftime date = strftime('%y%m%d') hour = strftime('%H%M%S')

  2. leetcode: Path Sum II 迭代法

    Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given su ...

  3. git 添加文件

    git 添加文件三步骤 git add filename git commit -m 'remarks' git push origin master

  4. BPM到底能做什么?K2为你解读

    和平镇,镇如其名,几百年来一直很和平,夜不闭户路不拾遗.可是这一年来,镇上金光寺的和尚却开始不断离奇死亡…… 衙门里新调来的李捕头正好负责这个案子,经过了几个月的不眠不休,现场侦查和缜密推理之后,一切 ...

  5. C#根据IP地址和子网掩码计算广播地址

    using System.Net; /// <summary> /// 获得广播地址 /// </summary> /// <param name="ipAdd ...

  6. 那些OVER的封装

    什么over什么,如pppoe, ppp的封装都在over对象之后,入下图: PPPOE   Ipsec

  7. pre标签避免一行过长打破格局

    pre{ white-space:pre-wrap; word-wrap:break-word; word-break:break-all }

  8. JQuery 如何选择带有多个class的元素

    Q: 比如下面代码需要选择同时带有这几个class的元素,怎么写? 1 <div class="modal fade in"></div> A: 1. 依次 ...

  9. MVC4项目中验证用户登录一个特性就搞定

    在开发过程中,需要用户登陆才能访问指定的页面这种功能,微软已经提供了这个特性. // 摘要: // 表示一个特性,该特性用于限制调用方对操作方法的访问. [AttributeUsage(Attribu ...

  10. 在opencv3中实现机器学习之:利用正态贝叶斯分类

    opencv3.0版本中,实现正态贝叶斯分类器(Normal Bayes Classifier)分类实例 #include "stdafx.h" #include "op ...