HDOJ 5387 Clock 水+模拟

ClockTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 316Accepted Submission(s): 215

Problem Description

Give a time.(hh:mm:ss),,you should answer the angle between any two of the minute.hour.second handNotice that the answer must be not more 180 and not less than 0

Input

There aretest casesfor 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 120

Hint

每行输出数据末尾均应带有空格

Source

/* ***********************************************Author:CKbossCreated 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_hmif(g1==120) printf("%d ",dur_hm/g1);else printf("%d/%d ",dur_hm/g1,120/g1);///print dur_hsif(g2==120) printf("%d ",dur_hs/g2);else printf("%d/%d ",dur_hs/g2,120/g2);///print dur_hsif(g3==120) printf("%d \n",dur_ms/g3);else printf("%d/%d \n",dur_ms/g3,120/g3);}return 0;}

版权声明:本文为博主原创文章,未经博主允许不得转载。

来说是非者,便是是非人。

HDOJ 5387 Clock 水+模拟

相关文章:

你感兴趣的文章:

标签云: