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. 前端的瑞士军刀:Modernizr.js

    前言 Modernizr.js既能给老版本浏览器打补丁,又能保证新浏览器渐进增强的用户体验. 作用: 从实际操作来看,Modernizr默认做的事情很少,除了(在你选择的情况下)给不支持html5的标 ...

  2. 2014 Super Training #2 F The Bridges of Kolsberg --DP

    原题:UVA 1172  http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...

  3. Doxygen Tool For Unity

    一.准备阶段 在之前的一系列文章中,我尝试了不同方法为Unity的C#生成脚本手册(帮助文档) 使用Doxygen生成C#帮助文档 为Unity项目生成文档(一)为Unity项目生成文档(二) 建议的 ...

  4. NGUI 3.x 练习

    一.常用快捷键 Alt+Shitf+W 创建一个新的 Widget Alt+Shift+S 创建一个新的 Sprite Alt+Shift+L 创建一个新的 Label Alt+Shift+T 创建一 ...

  5. 021医疗项目-模块二:药品目录的导入导出-介绍poi类

    我们使用的是.10版本 Apache POI - the Java API for Microsoft Documents,Apache POI 是用Java编写的免费开源的跨平台的 Java API ...

  6. 通过jekyll建立静态网页

    部署一个网站需要三个步骤:(1) generating the site, (2) deploying it to the public Internet, and (3) assigning it ...

  7. swift 判断输入的字符串是否为数字

    // 判断输入的字符串是否为数字,不含其它字符 func isPurnInt(string: String) -> Bool { let scan: Scanner = Scanner(stri ...

  8. C++ STL之vector详解

    转自http://blog.sina.com.cn/s/blog_9f1c0931010180cy.html Vectors   vector是C++标准模板库中的部分内容,它是一个多功能的,能够操作 ...

  9. java内部类 2016年12月13号

    1.在外部类的任意位置创建内部类对象的方法: 1)从外部类的非静态方法之外的任意位置创建某个内部类的对象,必须指明这个对象所在的外部类和内部类:OuterClassName.InnerClassNam ...

  10. 2016动作短片《全境封锁:特工起源》HD720P.英语中字

    导演: 德文·格雷厄姆主演: Matt Lynch / Sasha Andreev / Amanda Day类型: 动作 / 短片制片国家/地区: 美国语言: 英语上映日期: 2016-01-19片长 ...