hdu 5387 Clock 2015多校联合训练赛#8_GDRetop的博客-程序员秘密

技术标签: ##ACM-ICPC编程题  ACM之2015多校联合训练赛  2015多校联合训练赛  

Clock

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 328    Accepted Submission(s): 225


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 (1T104)  test cases
for each case,one line include the time

0hh<24 , 0mm<60 , 0ss<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



#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;


int gcd(int a,int b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
void work(int a,int b){
    int u = 120*360;
    int f = ((a-b)%u+u)%u;
    f = min(f,u-f);
    u = 120;
    int g = gcd(f,u);
    u /= g;
    f /= g;
    if(u == 1) printf("%d ",f);
    else printf("%d/%d ",f,u);
}
int main(){
    int t,h,m,s;
    scanf("%d",&t);
    while(t--){
        scanf("%d:%d:%d",&h,&m,&s);
        h = h*60*60+m*60+s;
        m = m*12*60+s*12;
        s = s*12*60;
        work(h,m);
        work(h,s);
        work(m,s);
        printf("\n");
    }
    return 0;
}


版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/firenet1/article/details/47659033

智能推荐

JVM基础(二) - 垃圾收集器与内存分配策略_未子涵的博客-程序员秘密

本文主要内容出自周志明老师《深入理解Java虚拟机》一书,是笔者结合自己的理解,提取重点,重新组织排版,再补充了一些内容后,总结的读书笔记。概述在 JVM 运行时 5 大数据区中,程序计数器、虚拟机栈、本地方法栈 3 个区域都是线程私有的,随线程而生,随线程而灭。这几个区域的内存分配和回收都具备确定性,不需要过多考虑回收的问题,因为方法结束或线程结束时,内存自然就跟着回收了。而Java堆...

kali2.0安装mysql,Ubuntu/kali上安装MySQL,设置远程访问详细教程_愿水长流的博客-程序员秘密

搜索热词Ubuntu上安装MysqL非常简单只需要几条命令就可以完成。1. sudo apt-get install MysqL-server2. apt-get installMysqL-client (可选)3. sudo apt-get install libMysqLclient-dev(可选)安装过程中会提示设置密码什么的,注意设置了不要忘了,安装完成之后可以使用如下命令来检查是否安装成...

保存和恢复模型-tensorflow_epoch:04d_AI强仔的博客-程序员秘密

相比原文,增加了目录编号,以便更好的理解记忆。0导入包,下载数据from future import absolute_import, division, print_function, unicode_literalsimport osimport tensorflow as tffrom tensorflow import kerasprint(tf.version.VERSION...

Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-res_dalter的博客-程序员秘密

idea打包错误 : 报错Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-res[错误]无法执行目标org.apache.maven网站.插件:maven资源插件:3.2.0:project xcx上的资源(默认资源):插件org.apache.maven网站.插件:maven资源插件:3.2.0需要Maven版本3.1.0-&gt;[帮助1]&lt;..

WebMail: roundcube的组建_亚伯拉罕7208的博客-程序员秘密

组建:Ubuntu server 8.04 + Apache2 + Postfix + Courier + Mysql + Roundcube + Saslauth一、点评:    本人参照网文http://www.howtoforge.com/virtual-users-domains-postfix-courier-mysql-squirrelmail-ubuntu8.04

爬虫小菜:你知道xpath中text()和string(.)的区别吗?_joker1993的博客-程序员秘密

我们在进行爬虫时候,经常会遇到如下这样的页面:&lt;span&gt; &lt;div&gt; &lt;em&gt;你好&lt;/em&gt;,北京 &lt;/div&gt;&lt;/span&gt;在日常抓取的时候,遇到更多的情况是抓取&lt;em&gt;中的你好,这时使用xpath("//div/em/text()")就可以提取到。现在我们考虑下...

随便推点

javascript中的原型_扑满大师的博客-程序员秘密

javascript中的原型关于js中prototype,在js程序员中已经是个老生长谈的话题了。 虽然说很简单,但是在新手中却常常造成困惑,那么就再次拎出来谈一谈。1 题目让我们从一个题目开始我们的话题,请看var f = function(){};f.prototype.obj = {name:"jack",age:18};var s = new f();s.obj.name = "tom";

VMware8.0 安装历程_静远的博客-程序员秘密

以前也用过VMware,每次安装都很顺利。这次因为想搭建一个测试环境,下了一个VM8.0安装,但是很不顺利,前前后后大概总共花费了三十个小时的样子。        两个错误提示,如下图,这是在尝试VM workstation失败后,尝试安装VM Player时的截图,VM workstation失败的提示大同小异。            下面说说我的安装历程。        刚

AFNetworking访问https出现"NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9806"_乞力马扎罗的雪CYF的博客-程序员秘密

在之前一篇博客中《AFNetworking访问https出现"NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813"》,而在这篇博客中的这个bug也是非常的类似。出现的场景也是服务端使用了自签名的证书,然后客户端按照《AFNetworking访问https出现"NSURLSession/NSURL

JAVA 8 的新特性_ZhouSanduo18的博客-程序员秘密

一、接口的默认方法Java 8允许我们给接口添加一个非抽象的方法实现,只需要使用 default关键字即可,这个特征又叫做扩展方法,示例如下: 代码如下:interface Formula { double calculate(int a); default double sqrt(int a) { return Math.sqrt(a); }}Formul

【线性表】双向链表的基本操作 指定结点交换_->previous->next_无白 | Herk (ง •̀_•́)ง的博客-程序员秘密

目录1.双向链表的基本操作2.双向链表的创建和打印3.指定值为x的结点与其前驱结点交换1.双向链表的基本操作#include &lt;iostream&gt;using namespace std;typedef int Elemtype;typedef struct LinkNode { Elemtype data; LinkNode *next, *previous;} * DLIST, *Node;void Delete(Node p){ //删除

odoo 建模失败psycopg2.OperationalError(‘Unable to use a closed cursor.‘)_"mac版odoo psycopg2.operationalerror: connection to_知识进脑的肖老千啊的博客-程序员秘密

odoo 建模失败,报错:psycopg2.OperationalError(‘Unable to use a closed cursor.’)稀里糊涂解决方式:我们是线上建模然后报错这玩意…我换了个账户建模…然后就好了 可能是线程问题。。?