题目传送门

 /*
模拟:这题没啥好说的,把指针转成角度处理就行了,有两个注意点:结果化简且在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. JS基础:正则表达式

    简介 正则表达式 (regular expression) 描述了一种字符串匹配的模式,可以用来检查一个字符串是否含有某种子串.将匹配的子串做替换或者从某个字符串中取出符合某个条件的子串等.在 JS ...

  2. ci框架(codeigniter)Email发送邮件、收件人、附件、Email调试工具

        ci框架(codeigniter)Email发送邮件.收件人.附件.Email调试工具 Email 类         CodeIgniter 拥有强大的 Email 类来提供如下的功能: 多 ...

  3. 洛谷——P2866 [USACO06NOV]糟糕的一天Bad Hair Day

    https://www.luogu.org/problem/show?pid=2866 题目描述 Some of Farmer John's N cows (1 ≤ N ≤ 80,000) are h ...

  4. html5视频播放器 二 (功能实现及播放优化)

    样式改写css,其中的一些按钮是在“阿里妈妈”上找的字体图标,就不向上传了. /* *CoolPlay视频播放器 * 2016年8月1日 * 627314658@qq.com * */ @font-f ...

  5. 文件I/O和标准I/O

    转载:https://blog.csdn.net/kyang_823/article/details/79496561 一.文件I/O和标准I/O文件I/O:文件I/O也称为不带缓冲的I/O(unbu ...

  6. Ubuntu 16.04粘贴板增强工具Diodon

    相比Parcellite(http://www.cnblogs.com/EasonJim/p/7119308.html),Diodon可以支持图片. 安装: sudo add-apt-reposito ...

  7. SetWindowsHookEx详解

    http://blog.csdn.net/mmllkkjj/article/details/6627188 函数功能:该函数将一个应用程序定义的挂钩处理过程安装到挂钩链中去,您可以通过安装挂钩处理过程 ...

  8. 【python】一些好的学习网址

    http://www.cnblogs.com/BeginMan/p/3179302.html http://www.cnblogs.com/huxi/category/251137.html http ...

  9. Tutorial: Synchronizing State with Mutexes in Go

    go语言中用mutex实现状态同步. 原文:https://kylewbanks.com/blog/tutorial-synchronizing-state-with-mutexes-golang - ...

  10. tomcat用80port能够启动,可是浏览器不显示tomcat首页

    一.打开执行(ctrl+r)->输入cmd->确定->输入netstat -ano 结果检測到 :80port被system 占用,如图所看到的 打开进程发现确实被 PID为 4 的 ...