HDU 5387 Clock (MUT#8 模拟)
【题目链接】: pid=5387">click here~~
【题目大意】给定一个时间点。求时针和分针夹角,时针和秒针夹角,分针和秒针夹角
模拟题,注意细节
代码:
#include<bits/stdc++.h>
using namespace std;
inline int read(){
int c=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){c=c*10+ch-'0';ch=getchar();}
return c*f;
}
int gcd(int a,int b){return b==0? a:gcd(b,a%b);}
int main(){
int t,h,m,s;
t=read();
while(t--){
scanf("%d:%d:%d",&h,&m,&s);
h%=12;
m%=60;
s%=60; int ss=s*720; //秒针走过的角度
int mm=720*m+12*s; //分针走过的角度
int hh=3600*h+60*m+s; //时针走过的角度 //计算角度之差
int hm=abs(hh-mm);
int hs=abs(hh-ss);
int ms=abs(mm-ss);
//推断
hm=min(hm,120*360-hm);
hs=min(hs,120*360-hs);
ms=min(ms,120*360-ms);
//取最大公约数
int ghm=gcd(hm,120);
int ghs=gcd(hs,120);
int gms=gcd(ms,120); if(ghm==120) cout<<hm/120;
else cout<<hm/ghm<<"/"<<120/ghm; if(ghs==120) cout<<" "<<hs/120<<" ";
else cout<<" "<<hs/ghs<<"/"<<120/ghs<<" "; if(gms==120) cout<<ms/120<<" "<<endl;
else cout<<ms/gms<<"/"<<120/gms<<" "<<endl;
} return 0;
}
HDU 5387 Clock (MUT#8 模拟)的更多相关文章
- HDU 5387 Clock(分数类+模拟)
题意: 给你一个格式为hh:mm:ss的时间,问:该时间时针与分针.时针与秒针.分针与秒针之间夹角的度数是多少. 若夹角度数不是整数,则输出最简分数形式A/B,即A与B互质. 解析: 先计算出总的秒数 ...
- HDU 5387 Clock
题意:给一个时间,求三个时针之间的夹角,分数表示. 解法:算算算.统一了一下分母. 代码: #include<stdio.h> #include<iostream> #incl ...
- 模拟 HDOJ 5387 Clock
题目传送门 /* 模拟:这题没啥好说的,把指针转成角度处理就行了,有两个注意点:结果化简且在0~180内:小时13点以后和1以后是一样的(24小时) 模拟题伤不起!计算公式在代码内(格式:hh/120 ...
- HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011亚洲北京赛区网络赛)
HDU 4041 Eliminate Witches! (模拟题 ACM ICPC 2011 亚洲北京赛区网络赛题目) Eliminate Witches! Time Limit: 2000/1000 ...
- 【模拟,时针分针秒针两两夹角】【没有跳坑好兴奋】hdu - 5387 (多校#8 1008)
算是最好写的一道题了吧,最近模拟没手感,一次过也是很鸡冻o(* ̄▽ ̄*)o 注意事项都在代码里,没有跳坑也不清楚坑点在哪~ #include<cstdio> #include<cst ...
- HDU 5705 Clock(模拟,分类讨论)
Clock Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submi ...
- HDOJ 5387 Clock 水+模拟
Clock Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Subm ...
- 【HDU 5387】Clock
题 Description Give a time.(hh:mm:ss),you should answer the angle between any two of the minute.hour. ...
- HDU 5948 Thickest Burger 【模拟】 (2016ACM/ICPC亚洲区沈阳站)
Thickest Burger Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
随机推荐
- Android 自己搭建一个直播系统吧
服务端用 SRS(Simple Rtmp Server),在这里下载simple-rtmp-server需要Linux系统最好是Ubuntu,装个Ubuntu虚拟机就行了在Linux里,解压缩SRS ...
- C#通过SqlConnection连接查询更新等操作Sqlserver数据库
Sqlserver数据库连接方式有多种,这里只介绍最常用的通过SqlConnection和Sqlserver数据库用户名和密码验证来进行操作数据库. 数据库连接字符串: string connStri ...
- Python 时间处理---------笔记
时区处理&格式化 import pytz from datetime import datetime # 设置时区 timezone = pytz.timezone('Asia/Shangha ...
- (转) 分布式文件存储FastDFS(一)初识FastDFS
http://blog.csdn.net/xingjiarong/article/details/50559849 一.FastDFS简介 FastDFS是一款开源的.分布式文件系统(Distribu ...
- C# 获得固定年月日
/// <summary> /// 获得固定年月日,时和分不固定 : 2019-01-01 00:00:00 /// </summary> /// <returns> ...
- excel求1加到100的和
强大的数组公式
- PHP 之中文转为拼音
/** * Created by PhpStorm. * User: Administrator * Date: 2019/1/2 0002 * Time: 下午 1:01 */ class PinY ...
- Docker是什么?可以用Docker做什么?
作者:刘允鹏 链接:https://www.zhihu.com/question/28300645/answer/67707287 来源:知乎 著作权归作者所有.商业转载请联系作者获得授权,非商业转载 ...
- 如何在mac里面,把xcode代码同步到 tfs 的 git库(新git库)
克隆篇请参考:http://www.cnblogs.com/IWings/p/6744895.html 在mac安装visual studio code https://code.visualstud ...
- [HDU] 4507 恨7不成妻
吉哥系列故事——恨7不成妻 Time Limit: 1000/500 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Tota ...