模拟 HDOJ 5387 Clock
/*
模拟:这题没啥好说的,把指针转成角度处理就行了,有两个注意点:结果化简且在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的更多相关文章
- HDOJ 5387 Clock 水+模拟
Clock Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Subm ...
- HDU 5387 Clock (MUT#8 模拟)
[题目链接]:pid=5387">click here~~ [题目大意]给定一个时间点.求时针和分针夹角,时针和秒针夹角,分针和秒针夹角 模拟题,注意细节 代码: #include&l ...
- hdoj 5387(Clock)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5387 比较水的一道题目,也是自己单翘的第一道题目吧,题意就是找到给定时间时钟三个指针之间的夹角, 需要 ...
- HDU 5387 Clock(分数类+模拟)
题意: 给你一个格式为hh:mm:ss的时间,问:该时间时针与分针.时针与秒针.分针与秒针之间夹角的度数是多少. 若夹角度数不是整数,则输出最简分数形式A/B,即A与B互质. 解析: 先计算出总的秒数 ...
- 模拟 HDOJ 5099 Comparison of Android versions
题目传送门 /* 题意:比较型号的大小 模拟:坑点在长度可能为5,此时设为'A' */ #include <cstdio> #include <algorithm> #incl ...
- 模拟 HDOJ 5095 Linearization of the kernel functions in SVM
题目传送门 /* 题意:表达式转换 模拟:题目不难,也好理解题意,就是有坑!具体的看测试样例... */ #include <cstdio> #include <algorithm& ...
- 模拟 HDOJ 4552 Running Rabbits
题目传送门 /* 模拟:看懂题意,主要是碰壁后的转向,笔误2次 */ #include <cstdio> #include <algorithm> #include <c ...
- HDU 5387 Clock
题意:给一个时间,求三个时针之间的夹角,分数表示. 解法:算算算.统一了一下分母. 代码: #include<stdio.h> #include<iostream> #incl ...
- 2015 Multi-University Training Contest 8
Hdu 5385 The path 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5385 题意:有一个联通的有向图,d(x)用来记录从1点到x点的最短 ...
随机推荐
- HDU 4416 (后缀自动机)
HDU 4416 Good Article Good sentence Problem : 给一个串S,和一些串T,询问S中有多少个子串没有在T中出现. Solution :首先对所有的T串建立后缀自 ...
- Linux下查看硬盘UUID和修改硬盘UUID(转)
查看硬盘UUID: 1. ls -l /dev/disk/by-uuid 2. blkid /dev/sda5 修改硬盘UUID: 1.新建和改变分区的UUID sudo uuidgen | xarg ...
- 集成学习(ensemble method)--基于树模型
bagging方法(自举汇聚法 bootstrap aggregating) boosting分类:最流行的是AdaBoost(adaptive boosting) 随机森林(random fores ...
- Chromium硬件加速渲染的UI合成过程分析
在Chromium中.Render端和WebGL端绘制出来的UI终于是通过Browser端显示在屏幕上的.换句话说.就是Browser端负责合成Render端和WebGL端的UI.这涉及到不同Open ...
- distcp导致个别datanode节点数据存储严重不均衡分析
hadoop2.4生产集群已经执行一段时间了.因为大量的hadoop1.0上面的应用不断迁移过来.刚開始事hdfs这边还没有出现多少问题.随着时间的推移,近期发现个别的datanode节点上面的磁盘空 ...
- SQLite数据库基本操作
SQLite 是一个开源的嵌入式关系数据库,实现自包容.零配置.支持事务的SQL数据库引擎. 其特点是高度便携.使用方便.结构紧凑.高效.可靠. 与其他数据库管理系统不同,SQLite 的安装和运行非 ...
- Linux 命令修改系统时间
修改linux的系统时间使用date指令,date命令的功能是显示和设置系统日期和时间. 输入date 查看目前系统时间. 修改时间需要 date -功能字符 修改内容 命令中各选项的含义分别为:-d ...
- luogu1966 火柴排队
题目大意 涵涵有两盒火柴,每盒装有 n 根火柴,每根火柴都有一个高度.现在将每盒中的火柴各自排成一列,同一列火柴的高度互不相同,两列火柴之间的距离定义为: $\sum_{i=1}^n(a_i-b_i) ...
- Proxy authentication confirmation prompt keeps popping up although the user/password is saved 火狐浏览器一直提示输入代理的账号和密码
https://support.mozilla.org/zh-CN/questions/943488 signon.autologin.proxy;true network.proxy.share_p ...
- 韩顺平Oracle笔记
韩顺平Oracle笔记 分类: DataBase2011-09-07 10:24 3009人阅读 评论(0) 收藏 举报 oracle数据库sqljdbcsystemstring 目录(?)[-] ...