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 ...
随机推荐
- ACM_“打老虎”的背后(简单并查集)
“打老虎”的背后 Time Limit: 2000/1000ms (Java/Others) Problem Description: “习大大”自担任国家主席以来大力反腐倡廉,各地打击贪腐力度也逐步 ...
- UNIX环境高级编程--6
系统数据文件和信息 数据文件都是ASCII文本文件,并且使用标准I/O库读这些文件,例如口令文件/etc/passwd和组文件/etc/group就是经常被多个程序频繁使用的两个文件. 口 ...
- vue-clickoutside d
js文件 export default { bind(el, binding, vnode) { function documentHandler(e) { if (el.contains(e.tar ...
- dedecms:解析Robots.txt 协议标准
Robots.txt 是存放在站点根目录下的一个纯文本文件.虽然它的设置很简单,但是作用却很强大.它可以指定搜索引擎蜘蛛只抓取指定的内容,或者是禁止搜索引擎蜘蛛抓取网站的部分或全部内容. 下面我们就来 ...
- fieldset ----- 不常用的HTML标签
fieldset 元素可将表单内的相关元素分组. <fieldset> 标签将表单内容的一部分打包,生成一组相关表单的字段. 当一组表单元素放到 <fieldset> 标签内时 ...
- JS——stye属性
1.样式少的时候使用 this.parentNode.style.backgroundColor="yellow"; 2.style是对象 console.log(box.styl ...
- CSS——border
表格细线: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...
- 【译】x86程序员手册18-6.3.1描述符保存保护参数
6.3 Segment-Level Protection 段级保护 All five aspects of protection apply to segment translation: 段转换时会 ...
- 离线安装Selenium
https://blog.csdn.net/poem_ruru/article/details/79032140
- PHP 之ip查询接口
/** * @param $ip 待查询的ip * @return mixed */ function getIpAddressInfo($ip) { $ipurl = 'http://api.ip1 ...