[水题] hdu5387 多校联合第八场 Clock
来源:互联网 发布:图片做成视频软件 编辑:程序博客网 时间:2024/06/04 17:59
Clock
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1320 Accepted Submission(s): 601
Problem Description
Give a time.(hh:mm:ss),you should answer the angle between any two of the minute.hour.second hand
Notice that the answer must be not more 180 and not less than 0
Notice that the answer must be not more 180 and not less than 0
Input
There are T (1≤T≤104) test cases
for each case,one line include the time
0≤hh<24 ,0≤mm<60 ,0≤ss<60
for each case,one line include the time
Output
for each case,output there real number like A/B.(A and B are coprime).if it's an integer then just print it.describe the angle between hour and minute,hour and second hand,minute and second hand.
Sample Input
400:00:0006:00:0012:54:5504:40:00
Sample Output
0 0 0 180 180 0 1391/24 1379/24 1/2 100 140 120Hint每行输出数据末尾均应带有空格
没别的,模拟一下就好了。。计算的时候注意取两边的夹角有可能是大于180度的角,这时候要算另外一边比较小的角。
#include <cstdio>#include <cstring>#include<cmath>#include<algorithm>using namespace std;int gcd(int a,int b){ if (b==0)return a; return gcd(b,a%b);}int main(){ int n; int hh,mm,ss; //freopen("in.txt","r",stdin); scanf("%d",&n); while(n--) { scanf("%d:%d:%d",&hh,&mm,&ss); //一圈总共有43200秒; int hour = 3600*hh + 60*mm + ss; int minute = 720*mm + 12*ss; int sec = 720*ss; while(hour >= 43200) hour -= 43200; while(minute >= 43200) minute -= 43200; while(sec >= 43200) sec -= 43200; int a1 = min(abs(hour - minute),43200-abs(hour-minute)); int a2 = min(abs(hour - sec),43200-abs(hour-sec)); int a3 = min(abs(minute -sec),43200-abs(minute - sec)); int b1,b2,b3; b1 = 120 / gcd(a1,120); b2 = 120 / gcd(a2,120); b3 = 120 / gcd(a3,120); b1 == 1 ? printf("%d ",a1/120):printf("%d/%d ",a1/gcd(a1,120),b1); b2 == 1 ? printf("%d ",a2/120):printf("%d/%d ",a2/gcd(a2,120),b2); b3 == 1 ? printf("%d ",a3/120):printf("%d/%d ",a3/gcd(a3,120),b3); printf("\n"); } return 0;}
0 0
- [水题] hdu5387 多校联合第八场 Clock
- hdu5387 六校 Clock(水题 模拟)
- 2014多校联合-第八场
- 多校联合第八场hdu5387Clock 最大公约数
- hdu5387 Clock
- hdu5387 Clock
- hdu5384 Danganronpa AC自动机 多校联合第八场
- [贪心] hdu5386 多校联合第八场 Cover
- [dp] hdu 5389 多校联合第八场 Zero Escape
- 2015多校联合第八场hdu5384Danganronpa AC自动机
- 2015多校联合第八场hdu5389Zero Escape DP
- HDU5387 Clock 时钟模拟
- 多校第八场
- 多校第八场
- 多校第八场
- hdu5387 Clock(数学水题)
- hdu5389 Zero Escape DP+滚动数组 多校联合第八场
- 2017多校联合第八场/hdu 6133 Army Formations(线段树合并)
- c++ cout 格式化输出浮点数、整数及格方法
- redis安装部署
- MVC模式下的命名规则
- TrafficStats——流量统计类的范例,获取实时网速
- HBase客户端API(整理 修改一下)
- [水题] hdu5387 多校联合第八场 Clock
- Python中文件读取readlines()方法
- JSON数组排序
- 把数组排成最小的数
- Andrew机器学习课程笔记(2)——神经网络、机器学习Tips
- UITextField使用步骤
- android成长
- C++ Primer 学习笔记与思考_4 ---getline&&size_type&&const_iterator混搭
- Linux--rsync实现文件同步