Clock

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 316    Accepted Submission(s): 215

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(1≤T≤104) test
cases

for each case,one line include the time



0≤hh<24,0≤mm<60,0≤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
每行输出数据末尾均应带有空格
 
Source
 

/* ***********************************************
Author :CKboss
Created Time :2015年08月13日 星期四 22时23分29秒
File Name :HDOJ5387.cpp
************************************************ */ #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map> using namespace std; int hh,mm,ss; int alltime(int h,int m,int s)
{
return h*3600+m*60+s;
} const int mod=360*120; int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout); int T_T;
scanf("%d",&T_T);
while(T_T--)
{
scanf("%d:%d:%d",&hh,&mm,&ss); int at=alltime(hh,mm,ss);
int hhdu=at%mod;
int mmdu=12*at%mod;
int ssdu=720*at%mod; int dur_hm=abs(mmdu-hhdu);
if(dur_hm>mod/2) dur_hm=mod-dur_hm; int dur_hs=abs(hhdu-ssdu);
if(dur_hs>mod/2) dur_hs=mod-dur_hs; int dur_ms=abs(mmdu-ssdu);
if(dur_ms>mod/2) dur_ms=mod-dur_ms; int g1=__gcd(dur_hm,120);
int g2=__gcd(dur_hs,120);
int g3=__gcd(dur_ms,120); ///print dur_hm
if(g1==120) printf("%d ",dur_hm/g1);
else printf("%d/%d ",dur_hm/g1,120/g1); ///print dur_hs
if(g2==120) printf("%d ",dur_hs/g2);
else printf("%d/%d ",dur_hs/g2,120/g2); ///print dur_hs
if(g3==120) printf("%d \n",dur_ms/g3);
else printf("%d/%d \n",dur_ms/g3,120/g3);
} return 0;
}

最新文章

  1. ROW_NUMBER over (order by **)
  2. Android实现与PHP服务器的交互
  3. 时间同步出现ntpdate[1788]: the NTP socket is in use, exiting
  4. OpenJudge计算概论-错误探测
  5. C#多态;父类引用指向子类对象;new和override的区别;new、abstract、virtual、override,sealed关键字区别和使用代码示例;c#类的初始化顺序
  6. android-support-xxxx.jar NoClassDefFoundError
  7. 移动web:转盘抽奖(幸运大转盘)
  8. VxWorks 基本启动方式
  9. protel dxp 2004安装与破解
  10. 实现鼠标悬停,div勾画div边框的动画
  11. leetcode 381.Insert Delete GetRandom
  12. C/C++ 多线程机制
  13. vhdl——type
  14. PHP函数可变参数
  15. Extending a logical volume in a virtual machine running Red Hat or Cent OS (1006371)
  16. 理解JavaWeb项目中的路径问题——相对路径与绝对路径
  17. WinFrom饼形图
  18. 使用JMAP dump及分析dump文件
  19. ComicEnhancerPro 系列教程十七:二值化图像去毛刺
  20. Windos Server Tomcat 双开配置

热门文章

  1. 输入一个字符串输出ASCII的十六进制值
  2. 单页vue路由router
  3. 03HibernateJAVA类与数据库表映射配置
  4. JS_类数组
  5. ORACLE中DBMS_SQL的用法
  6. node 转二进制 图片
  7. KBE实践——登录案例
  8. 小甲鱼Python学习笔记
  9. double salary = wage = 9999.99错误
  10. ubuntu环境安装docker