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. SpringCloud 微服务框架

    学习资源:https://ke.qq.com/course/280057 知识体系分为以下几点: 1)使用Eureka搭建注册中心,包括 服务生产者.服务消费者(也称服务注册与发现): Zookeep ...

  2. CREATE TRIGGER - 定义一个新的触发器

    SYNOPSIS CREATE TRIGGER name { BEFORE | AFTER } { event [ OR ... ] } ON table [ FOR [ EACH ] { ROW | ...

  3. 扩展 IHttpModule

    上篇提到请求进入到System.Web后,创建完HttpApplication对象后会执行一堆的管道事件,然后可以通过HttpModule来对其进行扩展,那么这篇文章就来介绍下如何定义我们自己的mod ...

  4. javascript——js string 转 int 注意的问题——parseInt(转)

    <script>     var   str='1250' ;  alert( Number(str) );  //得到1250 alert(parseInt(str));  //得到12 ...

  5. No-2.注释

    01. 注释的作用 使用用自己熟悉的语言,在程序中对某些代码进行标注说明,增强程序的可读性 02. 单行注释(行注释) 以 # 开头,# 右边的所有东西都被当做说明文字,而不是真正要执行的程序,只起到 ...

  6. CF147B Smile House

    题目大意:给定一个有向图,其中边有边权.求点数最少的正环的点数. 题解:建立矩阵,处理其二进制上每一位的状态.时间O(n^3*log(n)). 代码: #include<cstdio> # ...

  7. 在springBoot的控制台打印sql语句

    在springBoot+Mybatis日志显示SQL的执行情况的最简单方法就是在properties新增: properties形式 logging.level.com.eth.wallet.mapp ...

  8. linux纯字符界面不支持中文

    [2017-01-17] linux纯字符界面不支持中文

  9. Python之turtle库-小猪佩奇

    Python之turtle库-小猪佩奇 #!/usr/bin/env python # coding: utf-8 # Python turtle库官方文档:https://docs.python.o ...

  10. LeetCode(4)Median of Two Sorted Arrays

    题目 There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the ...