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;
}

HDOJ 5387 Clock 水+模拟的更多相关文章

  1. 模拟 HDOJ 5387 Clock

    题目传送门 /* 模拟:这题没啥好说的,把指针转成角度处理就行了,有两个注意点:结果化简且在0~180内:小时13点以后和1以后是一样的(24小时) 模拟题伤不起!计算公式在代码内(格式:hh/120 ...

  2. hdoj 5387(Clock)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5387 比较水的一道题目,也是自己单翘的第一道题目吧,题意就是找到给定时间时钟三个指针之间的夹角, 需要 ...

  3. CodeForces.158A Next Round (水模拟)

    CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...

  4. CodeForces.71A Way Too Long Words (水模拟)

    CodeForces71A. Way Too Long Words (水模拟) 题意分析 题怎么说你怎么做 没有坑点 代码总览 #include <iostream> #include & ...

  5. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  6. HDU 5387 Clock (MUT#8 模拟)

    [题目链接]:pid=5387">click here~~ [题目大意]给定一个时间点.求时针和分针夹角,时针和秒针夹角,分针和秒针夹角 模拟题,注意细节 代码: #include&l ...

  7. HDOJ 1008. Elevator 简单模拟水题

    Elevator Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Su ...

  8. HDU 5387 Clock(分数类+模拟)

    题意: 给你一个格式为hh:mm:ss的时间,问:该时间时针与分针.时针与秒针.分针与秒针之间夹角的度数是多少. 若夹角度数不是整数,则输出最简分数形式A/B,即A与B互质. 解析: 先计算出总的秒数 ...

  9. Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) A B C D 水 模拟 并查集 优先队列

    A. Broken Clock time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

随机推荐

  1. css 动态导入css文件 @import 动态js加载 都是静态的

    @import "http://apps.bdimg.com/libs/bootstrap/3.3.4/css/bootstrap.css" /*-防止各大cdn公共库加载地址失效 ...

  2. CAD参数绘制半径标注(com接口)

    主要用到函数说明: _DMxDrawX::DrawDimRadial 绘制一个半径标注.详细说明如下: 参数 说明 DOUBLE dCenterX 被标注的曲线的中点X值 DOUBLE dCenter ...

  3. CentOS 初体验十四:阿里云安装Gitlab

    网址:https://about.gitlab.com/install/#centos-7 https://blog.csdn.net/zhaoyanjun6/article/details/7914 ...

  4. C#线程锁使用全功略

    C#线程锁使用全功略 前两篇简单介绍了线程同步lock,Monitor,同步事件EventWaitHandler,互斥体Mutex的基本用法,在此基础上,我们对 它们用法进行比较,并给出什么时候需要锁 ...

  5. 诊断:ORA-00376 & ORA-01110

    现象: Errors in file /path/of/diag/rdbms/prod/PROD/trace/PROD_ora_13447.trc: ORA-00376: 此时无法读取文件 61 OR ...

  6. Spring中注解注入bean和配置文件注入bean

    注解的方式确实比手动写xml文件注入要方便快捷很多,省去了很多不必要的时间去写xml文件 按以往要注入bean的时候,需要去配置一个xml,当然也可以直接扫描包体,用xml注入bean有以下方法: & ...

  7. Java的类加载

    虚拟机把描述类的数据从Class文件加载到内存,并对数据进行校验.转换解析和初始化,最终形成可以被虚拟机直接使用的Java类型,这就是Java虚拟机的类加载机制 ----类加载的大致过程 类的加载的过 ...

  8. 零基础入门学习Python(36)--类和对象:给大家介绍对象

    知识点 Python3 面向对象 Python从设计之初就已经是一门面向对象的语言,正因为如此,在Python中创建一个类和对象是很容易的.本章节我们将详细介绍Python的面向对象编程. 如果你以前 ...

  9. SAX解析XML-例子

    1.要解析的xml <?xml version="1.0" encoding="UTF-8"?> <employees> <emp ...

  10. day 21 03 补全异常处理

    day 21 03  异常处理(补全) 1.异常处理的整体几个语句: try: .......#有可能出错的代码 ret=int(input('number >>>')) print ...