题意:给一个时间,求三个时针之间的夹角,分数表示。

解法:算算算。统一了一下分母。

代码:

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<time.h>
#include<stdlib.h>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#define LL long long
using namespace std;
int main()
{
int T;
while(~scanf("%d", &T))
{
while(T--)
{
int hh, mm, ss;
scanf("%d:%d:%d", &hh, &mm, &ss);
int hs = hh * 3600 + mm * 60 + ss;
int ms = mm * 60 + ss;
ms *= 12;
ss *= 120 * 6;
hs %= 43200;
ms %= 43200;
ss %= 43200;
int hhmm = abs(hs - ms);
if(hhmm > 120 * 180)
hhmm = 120 * 360 - hhmm;
int hhss = abs(hs - ss);
if(hhss > 120 * 180)
hhss = 120 * 360 - hhss;
int mmss = abs(ms - ss);
if(mmss > 120 * 180)
mmss = 120 * 360 - mmss;
int r = __gcd(hhmm, 120);
if(r == 120 || hhmm == 0)
printf("%d", hhmm / 120);
else
printf("%d/%d", hhmm / r, 120 / r);
r = __gcd(hhss, 120);
if(r == 120 || hhss == 0)
printf(" %d", hhss / 120);
else
printf(" %d/%d", hhss / r, 120 / r);
r = __gcd(mmss, 120);
if(r == 120 || mmss == 0)
printf(" %d ", mmss / 120);
else
printf(" %d/%d ", mmss / r, 120 / r);
puts("");
}
}
return 0;
}

  

HDU 5387 Clock的更多相关文章

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

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

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

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

  3. 模拟 HDOJ 5387 Clock

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

  4. 【HDU 5387】Clock

    题 Description Give a time.(hh:mm:ss),you should answer the angle between any two of the minute.hour. ...

  5. HDU 5705 Clock(模拟,分类讨论)

    Clock Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submi ...

  6. HDU——1393Weird Clock(水题,注意题意)

    Weird Clock Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  7. HDOJ 5387 Clock 水+模拟

    Clock Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Subm ...

  8. hdu 1209 Clock

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

  9. HDU 5705 Clock (精度控制,暴力)

    题意:给定一个开始时间和一个角度,问你下一个时刻时针和分针形成这个角度是几点. 析:反正数量很小,就可以考虑暴力了,从第一秒开始暴力,直到那个角度即可,不会超时的,数目很少,不过要注意精度. 代码如下 ...

随机推荐

  1. Unique Binary Search Tree II

    Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For e ...

  2. 在实体注解OneToMany时,要加上mappedby,避免产生中间表。

    在实体注解OneToMany时,要加上mappedby,避免产生中间表.

  3. JAVA WEB中如何让数据库连接对开发人员完全透明?

    书上的技术,确实开了眼界. 列相关测试代码如下,慢慢体会开发的模式. PropsUtil package org.smart4j.chapter2.util; import java.io.FileN ...

  4. Qt4升级Qt5注意问题

    Qt4升级Qt5注意问题 Qt4过渡到Qt5的项目一开始就受阻,记录一下遇到的下面的问题 --->编译遇到类似错误: error: QCalendarWidget: No such file o ...

  5. 百度地图API简单使用

    百度地图API是由JavaScript语言编写的,在使用之前需要将API引用到页面中:  现在新版本的需要密钥,下面用的是旧版的 <script src="http://api.map ...

  6. Redis是什么?

    1. Redis是什么 这个问题的结果影响了我们怎么用Redis.如果你认为Redis是一个key value store, 那可能会用它来代替MySQL;如果认为它是一个可以持久化的cache, 可 ...

  7. OpenCV码源笔记——RandomTrees (一)

    OpenCV2.3中Random Trees(R.T.)的继承结构: API: CvRTParams 定义R.T.训练用参数,CvDTreeParams的扩展子类,但并不用到CvDTreeParams ...

  8. 车牌识别LPR(三)-- LPR系统整体结构

    第三篇:系统的整体架构 LPR系统大体上可由图像采集系统,图像处理系统,数据库管理系统三个子系统组成.它综合了通讯.信息.控制.传感.计算机等各种先进技术,构成一个智能电子系统. 图像采集系统:图像采 ...

  9. sh.exe": grunt: command not found

    今天在git命令行工具中使用 grunt的时候,总是提示我找不到grunt命令,如: sh.exe": grunt: command not found 但是我运行 npm install ...

  10. Android中使用广播机制退出多个Activity

    谷歌百度一下,Android中退出多个Activity的方法,大家讨论的很多. 在实习的时候,看到公司的项目退出多个Activity,是采用LinkedList方法,毕业设计的时候,也参照了那种方法. ...