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. Vue路由模式及监听

    当然详细情况还是看一下vue的官网吧 官网https://router.vuejs.org/zh/   hash模式下(默认) new VueRouter({ mode : ‘hash’, route ...

  2. C# html table转excel

    1. protected void ebtDC_Click(object sender, EventArgs e) { string elxStr = "<table><t ...

  3. delphi byte to of set

    最佳方案 type // Controls.TCMMouseWheel relies on TShiftState not exceeding 2 bytes in size TShiftState ...

  4. myeclipse出现Failed to load JavaHL Library.

    eclipse启动出现如图的状况: 解决方法: Window-Preferences-Team-SVN,在SVN接口的下拉框可以看到,默认选择的是JavaHL(JNI) Not Available,手 ...

  5. sqllite相关总结

    一,sqlite 简介 前面写了一篇博文讲如何在 C# 中使用 ADO 访问各种数据库,在移动开发和嵌入式领域也有一个轻量级的开源关系型数据库-sqlite.它的特点是零配置(无需服务器),单磁盘文件 ...

  6. svn in xcode5

    两种办法,一是使用比较成熟的svn客户端,二是使用终端.以下为终端方法: 假设已经通过Xcode->Preferences->Accounts将repository: http://mys ...

  7. 诊断:AWR快照停止自动采集

    11.2.0.4数据库中,MMON进程,有时候由于一些莫名其妙的原因挂掉,接下来AWR的快照也就无法正常自动生成.MMON进程应该自动重启,却并没有自动被启动. 那么我们有可能是遇到了bug Bug ...

  8. vue 全局组件的注册

    第一步 在main.js里面 引入需要注册的组件例如: //引入组件 import header from  './components/header.vue' import footer from ...

  9. 黑马毕向东Java基础知识总结

    Java基础知识总结(超级经典) 转自:百度文库 黑马毕向东JAVA基础总结笔记    侵删! 写代码: 1,明确需求.我要做什么? 2,分析思路.我要怎么做?1,2,3. 3,确定步骤.每一个思路部 ...

  10. Centos6 安装nginx

    一.编译安装nginx 1.安装nginx所需要的库pcre,pcre的全称为:perl compatible regular expression即perl正则表达式,是为了使nginx具备URL重 ...