题目传送门

 /*
模拟:这题没啥好说的,把指针转成角度处理就行了,有两个注意点:结果化简且在0~180内;小时13点以后和1以后是一样的(24小时)
模拟题伤不起!计算公式在代码内(格式:hh/120, mm/120, ss/120)
*/
/************************************************
* Author :Running_Time
* Created Time :2015-8-13 13:04:31
* File Name :H.cpp
************************************************/ #include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std; #define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int MAXN = 1e5 + ;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + ;
char str[]; int GCD(int a, int b) {
return (b == ) ? a : GCD (b, a % b);
} int main(void) { //HDOJ 5387 Clock
int T; scanf ("%d", &T);
while (T--) {
int h = , m = , s = ;
int hh[], mm[], ss[];
scanf ("%s", str + );
h = (h + (str[] - '')) * + str[] - '';
m = (m + (str[] - '')) * + str[] - '';
s = (s + (str[] - '')) * + str[] - ''; if (h >= ) h -= ; //WA点 hh[] = * h + * m + s; //角度
mm[] = * m + * s;
ss[] = * s; int tmp = hh[]; //计算角度差,要在0~180度内
hh[] = abs (hh[] - mm[]);
hh[] = min (hh[], * - hh[]);
int tmp2 = mm[];
mm[] = abs (tmp - ss[]);
mm[] = min (mm[], * - mm[]);
ss[] = abs (tmp2 - ss[]);
ss[] = min (ss[], * - ss[]); hh[] = GCD (, hh[]); //求GCD,化简
mm[] = GCD (, mm[]);
ss[] = GCD (, ss[]); if (hh[] % == ) { //输出
printf ("%d ", hh[] / );
}
else {
printf ("%d/%d ", hh[] / hh[], / hh[]);
}
if (mm[] % == ) {
printf ("%d ", mm[] / );
}
else {
printf ("%d/%d ", mm[] / mm[], / mm[]);
}
if (ss[] % == ) {
printf ("%d \n", ss[] / );
}
else {
printf ("%d/%d \n", ss[] / ss[], / ss[]);
}
} return ;
}

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

  1. HDOJ 5387 Clock 水+模拟

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

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

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

  3. hdoj 5387(Clock)

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

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

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

  5. 模拟 HDOJ 5099 Comparison of Android versions

    题目传送门 /* 题意:比较型号的大小 模拟:坑点在长度可能为5,此时设为'A' */ #include <cstdio> #include <algorithm> #incl ...

  6. 模拟 HDOJ 5095 Linearization of the kernel functions in SVM

    题目传送门 /* 题意:表达式转换 模拟:题目不难,也好理解题意,就是有坑!具体的看测试样例... */ #include <cstdio> #include <algorithm& ...

  7. 模拟 HDOJ 4552 Running Rabbits

    题目传送门 /* 模拟:看懂题意,主要是碰壁后的转向,笔误2次 */ #include <cstdio> #include <algorithm> #include <c ...

  8. HDU 5387 Clock

    题意:给一个时间,求三个时针之间的夹角,分数表示. 解法:算算算.统一了一下分母. 代码: #include<stdio.h> #include<iostream> #incl ...

  9. 2015 Multi-University Training Contest 8

    Hdu 5385 The path 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5385 题意:有一个联通的有向图,d(x)用来记录从1点到x点的最短 ...

随机推荐

  1. 网络编程基础:网络基础之网络协议、socket模块

    操作系统(简称OS)基础: 应用软件不能直接操作硬件,能直接操作硬件的只有操作系统:所以,应用软件可以通过操作系统来间接操作硬件 网络基础之网络协议: 网络通讯原理: 连接两台计算机之间的Intern ...

  2. 【中文排序】mysql order by 中文排序

    1. 在MySQL中,我们经常会对一个字段进行排序查询,但进行中文排序和查找的时候,对汉字的排序和查找结果往往都是错误的. 这种情况在MySQL的很多版本中都存在. 如果这个问题不解决,那么MySQL ...

  3. 本地配置nginx的https

    前文:因为要用谷歌下的getUserMedia方法,而getUserMedia方法只能在https下才能调用,所以在本地搭建https来测试,现在说说步骤. 步骤1:下载nginx-1.10.3.zi ...

  4. [bzoj4519][Cqoi2016]不同的最小割_网络流_最小割_最小割树

    不同的最小割 bzoj-4519 Cqoi-2016 题目大意:题目链接. 注释:略. 想法: 我们发现这和最小割那题比较像. 我们依然通过那个题说的办法一样,构建最小割树即可. 接下来就是随便怎么处 ...

  5. POJ2632 Crashing Robots 解题报告

    Description In a modernized warehouse, robots are used to fetch the goods. Careful planning is neede ...

  6. Mybatis教程(一)

    1      Mybatis教程(一) 学习过的持久层框架:DBUtils , Hibernate Mybatis就是类似于hibernate的orm持久层框架. 为什么学Mybatis? 目前最主流 ...

  7. json数组显示格式

    {“colorAndImg”:[{"颜色":“红色”,"地址":“www.sohu.com”}, {“颜色”:“绿色,“地址”:“www.sohu.com”}] ...

  8. linux复制文件/移动文件从一个文件夹到另一个文件夹

    cp ~/baidu/* ~/zhidao/cp -r逐层复制mv /data/link /usr/local 移动文件夹 解决方法 1.在cp命令后,加一个选项 -r . cp -r  /TEST/ ...

  9. Windows系统下查看已共享的文件夹的方法

    电脑使用时间比较长,共享过好几次文件夹,现在想取消共享,但共享文件夹的路径隐藏得太深,要怎么样才能快速找到共享文件夹的实际路径呢?” “其实现在单位常见的方法都是用网上邻居的共享文件夹,共享的文件夹也 ...

  10. 子元素设置margin-top,父元素也受影响

    这个问题困惑了非常久.尽管没有大碍早就摸出来怎么搞定它.但始终不明确原因出在哪里,假设仅仅是IE有问题我也不会太在意.可问题是全部上等浏览器都表现如此,这样叫我怎能安心?今天总算下狠心查出来怎么回事, ...