题目传送门

 /*
模拟:这题没啥好说的,把指针转成角度处理就行了,有两个注意点:结果化简且在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数组转换成json串 (JSON.stringify)

    例如: var giftlist[1490011777] = []; giftlist[1490011777]['id'] = 1490011777; giftlist[1490011777]['na ...

  2. Java Web 总结

    Java Servlet 总结 Servlet 简介 Servlet 是什么? 运行在Web服务器上的应用程序,作为浏览器和服务器之间的中间层. 与CGI功能类似,优点在于 性能更好 在Web服务器的 ...

  3. Codeforces 799E(贪心)

    题意: 有n个物品,购买物品i需要花费ci的代价.Arkady和Masha分别有喜欢的物品. 现在需要从中选m个,使得这m个物品中至少有k个Arkady喜欢的物品,k个Masha喜欢的物品. 输出满足 ...

  4. 彻底来理解下hashmap吧

    1.什么叫hashmap? 答:首先是一种map集合,其次呢,它是一种利用hash表来存储的数据结构.所以叫hashmap. 2.hashmap的特点是什么? 答:hashmap的特点是key值不能重 ...

  5. [Javascript] Flattening nested arrays: a little exercise in functional refactoring

    In this lesson we write an imperative function to flatten nested arrays, and then use the popular ma ...

  6. Struts2默认拦截器栈及内建拦截器使用具体解释

    Struts2内建拦截器介绍:   alias (别名拦截器):同意參数在跨越多个请求时使用不同别名,该拦截器可将多个Action採用不同名字链接起来,然后用于处理同一信息.  autowiring  ...

  7. Android小技巧总结1

    0.Android彻底退出引用程序的方法 1) Dalvik VM的本地方法 android.os.Process.killProcess(android.os.Process.myPid()); / ...

  8. Android在onCreate()方法中动态获取TextView控件的高度

    正好朋友项目里遇到了给写了个小Demo: 这个监听器看名字也知道了.就是在绘画完毕之前调用的,在这里面能够获取到行数.当然也能够获取到宽高等信息 package com.example.textvie ...

  9. Spark技术内幕:Master基于ZooKeeper的High Availability(HA)源代码实现

    假设Spark的部署方式选择Standalone,一个採用Master/Slaves的典型架构,那么Master是有SPOF(单点故障,Single Point of Failure).Spark能够 ...

  10. Android Studio 使用 SVN 必然遇到问题:commit ** File out of data 问题解决方法

    转载请注明:http://blog.csdn.net/lrs123123/article/details/44829579 Android Studio 的使用已经越来越成为趋势.而结合版本号控制工具 ...