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_Ruin of Titanic(简单贪心)
Ruin of Titanic Time Limit: 2000/1000ms (Java/Others) Problem Description: 看完Titanic后,小G做了一个梦.梦见当泰坦尼 ...
- Android内存管理(9)*MAT:Heap Dump,Shallow Heap,Retained Heap,Dominating Tree,GC Roots等的含义
原文: http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.mat.ui.help%2Fconcepts%2Fheapdump.ht ...
- 【LeetCode】-- 73. Set Matrix Zeroes
问题描述:将二维数组中值为0的元素,所在行或者列全set为0:https://leetcode.com/problems/set-matrix-zeroes/ 问题分析:题中要求用 constant ...
- Unity学习-鼠标的常用操作(八)
本次主要介绍5个鼠标事件 void OnMouseEnter():鼠标进入 void OnMouseExit():鼠标移出 void OnMouseDown():鼠标点击 void OnMouseUp ...
- 安卓socket 心跳和信鸽自定义提示音
/** * 连接socket 和心跳 */ public class SocketService extends Service { private static addNewOrderInterfa ...
- HTML CSS, JavaScript 计算器
效果图: 代码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> < ...
- java攻城师之路--复习java web之request_respone
Servlet技术 两条主线1.HTTP协议 2.Servlet生命周期 init() 方法中参数 ServletConfig 对象使用通过ServletConfig 获得 ServletContex ...
- Codeforces_738B
B. Spotlights time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- HDU_1285_拓扑排序(优先队列)
确定比赛名次 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Subm ...
- VS单元测试"未能加载文件或程序集,或它的某一个依赖项"
Autofac.Core.DependencyResolutionException : An error occurred during the activation of a particular ...