HDU 5387 Clock
题意:给一个时间,求三个时针之间的夹角,分数表示。
解法:算算算。统一了一下分母。
代码:
#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的更多相关文章
- HDU 5387 Clock (MUT#8 模拟)
[题目链接]:pid=5387">click here~~ [题目大意]给定一个时间点.求时针和分针夹角,时针和秒针夹角,分针和秒针夹角 模拟题,注意细节 代码: #include&l ...
- HDU 5387 Clock(分数类+模拟)
题意: 给你一个格式为hh:mm:ss的时间,问:该时间时针与分针.时针与秒针.分针与秒针之间夹角的度数是多少. 若夹角度数不是整数,则输出最简分数形式A/B,即A与B互质. 解析: 先计算出总的秒数 ...
- 模拟 HDOJ 5387 Clock
题目传送门 /* 模拟:这题没啥好说的,把指针转成角度处理就行了,有两个注意点:结果化简且在0~180内:小时13点以后和1以后是一样的(24小时) 模拟题伤不起!计算公式在代码内(格式:hh/120 ...
- 【HDU 5387】Clock
题 Description Give a time.(hh:mm:ss),you should answer the angle between any two of the minute.hour. ...
- HDU 5705 Clock(模拟,分类讨论)
Clock Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submi ...
- HDU——1393Weird Clock(水题,注意题意)
Weird Clock Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- HDOJ 5387 Clock 水+模拟
Clock Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Subm ...
- hdu 1209 Clock
Clock Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- HDU 5705 Clock (精度控制,暴力)
题意:给定一个开始时间和一个角度,问你下一个时刻时针和分针形成这个角度是几点. 析:反正数量很小,就可以考虑暴力了,从第一秒开始暴力,直到那个角度即可,不会超时的,数目很少,不过要注意精度. 代码如下 ...
随机推荐
- Caching Tutorial
for Web Authors and Webmasters This is an informational document. Although technical in nature, it a ...
- [转载]Spring Annotation Based Configuration
Annotation injection is performed before XML injection, thus the latter configuration will override ...
- POJ 3421
X-factor Chains Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5111 Accepted: 1622 D ...
- POJ 1666
#include<iostream> using namespace std; int main() { int num_stu; int i; ; do{ time=; cin>& ...
- C# 构造函数的使用方法
C#构造函数是一个特殊的类方法.在很多方面,包括访问修饰符.重载以及参数列表的语法等方面,构造函数与普通的方法是类似的.然而,在使用方面以及行为方面,构造函数也具有许多特殊的语法和语义规则. 下面列出 ...
- hdu 2149 Public Sale (博弈规律题)
#include<stdio.h> int main() { int n,m; while(scanf("%d %d",&m,&n)!=EOF) { ) ...
- *[hackerrank]Consecutive Subsequences
https://www.hackerrank.com/contests/w6/challenges/consecutive-subsequences 求数组中被k整除的子段和有几个.这个要利用sum[ ...
- 修改Eclipse字体
选择菜单:Windows->Preferences->Genneral->Appearance->Colors and Font
- PowerDesigner模型设计
原文:PowerDesigner模型设计 绪论 Sybase PowerDesigner(简称PD)是最强大的数据库建模工具,市场占有率第一,功能也确实十分强大,现在最新版本是15.1,已经支持最新的 ...
- WP之Sql Server CE数据库
如何在WP8中进行数据存储,你首先想到应该是独立存储,但是独立存储似乎存储文件更方便,如果我们希望像处理对象的形式,该怎么办呢,答案就是Sql Server CE. Sql Server CE并不是新 ...