"Topic link": Click here~~
"topic" Given a point in time, the angle between the hour and minute hand, the hour and second hand angle, the minute hand and the second hand angle
Simulation questions, attention to detail
Code:
#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; The second hand passes the angle int mm=720*m+12*s; The minute hand passes the angle int hh=3600*h+60*m+s; The angle that the hour hand passes//calculates the difference of the angle int hm=abs (HH-MM); int Hs=abs (HH-SS); int Ms=abs (MM-SS); Judge Hm=min (HM,120*360-HM); Hs=min (HS,120*360-HS); Ms=min (MS,120*360-MS); Take greatest common divisor int ghm=gcd (hm,120); int GHS=GCD (hs,120); int GMS=GCD (ms,120); if (ghm==120) cout<
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
HDU 5387 Clock (mut#8 analog)