hdu 5387
来源:互联网 发布:淘宝卖家进货app用什么 编辑:程序博客网 时间:2024/04/28 04:45
Clock
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 311 Accepted Submission(s): 212
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每行输出数据末尾均应带有空格
题目大意:给出时间h: m: s ,求出三个指针的角度
思 路 :首先确认的一点是s转一圈走360下,跳一下就是1度 时针的角度要加上分针和秒针对应的角度 分针也是
因此需要算出三个针的角度再互相减去,同时保证数据在180 度以内
代码如下:
/*踏实!!努力!!*/#include<iostream>#include<algorithm>#include<string>#include<sstream>#include<set>#include<vector>#include<stack>#include<map>#include<queue>#include<deque>#include<cstdlib>#include<cstdio>#include<cstring>#include<cmath>#include<ctime>#include<cctype>#include<functional>using namespace std;int gcd(int a,int b){ if(b==0) return a; return gcd(b,a%b);}void work(int t1,int t2){ int t=abs(t1-t2); int k=120; if(t>180*k) t=360*k-t; int g=gcd(t,k); if(k/g==1) printf("%d ",t/g); else printf("%d/%d ",t/g,k/g);}int main(){ int t,h,m,s; scanf("%d",&t); while(t--){ scanf("%d:%d:%d",&h,&m,&s); int hh,mm,ss; if(h>=12) h-=12; //先化为整数 全部乘以120 ss=s*720; mm=m*720+s*12; hh=h*3600+m*60+s; work(hh,mm); work(hh,ss); work(mm,ss); printf("\n"); } return 0;}
0 0
- hdu 5387
- hdu 5387 Clock
- hdu 5387 Clock
- hdu 5387 Clock 多校
- HDU 5387 Clock
- HDU 5387 Clock
- HDU 5387 Clock // 模拟
- HDU 5387 Clock
- hdu 5387 Clock
- HDU 5387 Clock
- hdu 5387 Clock
- HDU 5387 乱搞
- hdu 5387 Clock
- HDU 5387 Clock
- hdu
- hdu
- HDU
- hdu ()
- Android使用gradle不同配置多项目打包
- 线段树区间更新hdu1698
- 人脸姿态估计浅谈~
- redis技术之旅二
- js 复制网页内容,兼容各浏览器
- hdu 5387
- mysql关键字
- 什么是 HTML?
- PHP中include_path
- OpenMANO初探
- 2016校招华为机试题目回忆1
- VC++获取病毒的消息钩子
- iOS概念入门学习-C语言-指针
- iOS_UITableView 编辑(cell的插入, 删除, 移动)