首页 > 代码库 > HDOJ 5387 Clock 水+模拟
HDOJ 5387 Clock 水+模拟
Clock
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 316 Accepted Submission(s): 215
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
4 00:00:00 06:00:00 12:54:55 04:40:00
Sample Output
0 0 0 180 180 0 1391/24 1379/24 1/2 100 140 120Hint每行输出数据末尾均应带有空格
Source
2015 Multi-University Training Contest 8
/* *********************************************** Author :CKboss Created Time :2015年08月13日 星期四 22时23分29秒 File Name :HDOJ5387.cpp ************************************************ */ #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <string> #include <cmath> #include <cstdlib> #include <vector> #include <queue> #include <set> #include <map> using namespace std; int hh,mm,ss; int alltime(int h,int m,int s) { return h*3600+m*60+s; } const int mod=360*120; int main() { //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int T_T; scanf("%d",&T_T); while(T_T--) { scanf("%d:%d:%d",&hh,&mm,&ss); int at=alltime(hh,mm,ss); int hhdu=at%mod; int mmdu=12*at%mod; int ssdu=720*at%mod; int dur_hm=abs(mmdu-hhdu); if(dur_hm>mod/2) dur_hm=mod-dur_hm; int dur_hs=abs(hhdu-ssdu); if(dur_hs>mod/2) dur_hs=mod-dur_hs; int dur_ms=abs(mmdu-ssdu); if(dur_ms>mod/2) dur_ms=mod-dur_ms; int g1=__gcd(dur_hm,120); int g2=__gcd(dur_hs,120); int g3=__gcd(dur_ms,120); ///print dur_hm if(g1==120) printf("%d ",dur_hm/g1); else printf("%d/%d ",dur_hm/g1,120/g1); ///print dur_hs if(g2==120) printf("%d ",dur_hs/g2); else printf("%d/%d ",dur_hs/g2,120/g2); ///print dur_hs if(g3==120) printf("%d \n",dur_ms/g3); else printf("%d/%d \n",dur_ms/g3,120/g3); } return 0; }
HDOJ 5387 Clock 水+模拟
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。