Analog Hdoj 5387 Clock

Source: Internet
Author: User

Topic Portal

1 /*2 Simulation: This problem is not much to say, the pointer to the angle of processing on the line, there are two points of attention: the results of simplification and within the 0~180; hours 13 and after 1 is the same (24 hours)3 The simulation problem can't afford to hurt! Calculate formulas within code (format: hh/120, mm/120, ss/120)4 */5 /************************************************6 * Author:running_time7 * Created time:2015-8-13 13:04:318 * File name:h.cpp9  ************************************************/Ten  One#include <cstdio> A#include <algorithm> -#include <iostream> -#include <sstream> the#include <cstring> -#include <cmath> -#include <string> -#include <vector> +#include <queue> -#include <deque> +#include <stack> A#include <list> at#include <map> -#include <Set> -#include <bitset> -#include <cstdlib> -#include <ctime> - using namespacestd; in  - #defineLson L, Mid, RT << 1 to #defineRson mid + 1, R, RT << 1 | 1 +typedefLong Longll; - Const intMAXN = 1e5 +Ten; the Const intINF =0x3f3f3f3f; * Const intMOD = 1e9 +7; $ Charstr[ One];Panax Notoginseng  - intGCD (intAintb) { the     return(b = =0) ? A:GCD (b, a%b); + } A  the intMainvoid)    {//hdoj 5387 Clock +     intT scanf ("%d", &T); -      while(t--) { $         inth =0, M =0, S =0; $         inthh[2], mm[2], ss[2]; -scanf ("%s", str +1); -H = (H + (str[1] -'0')) *Ten+ str[2] -'0'; them = (M + (str[4] -'0')) *Ten+ str[5] -'0'; -s = (s + (str[7] -'0')) *Ten+ str[8] -'0';Wuyi  the         if(H >= A) H-= A;//WA Point -  Wuhh[0] =3600* H + -* m + s;//Angle -mm[0] =720* m + A*s; Aboutss[0] =720*s; $  -         intTMP = hh[0];//Calculate the angle difference, to be within the 0~180度 -hh[0] = ABS (hh[0]-mm[0]); -hh[0] = min (hh[0], the* --hh[0]); A         intTMP2 = mm[0]; +mm[0] = ABS (tmp-ss[0]); themm[0] = min (mm[0], the* --mm[0]); -ss[0] = ABS (tmp2-ss[0]); $ss[0] = min (ss[0], the* --ss[0]); the          thehh[1] = GCD ( -, hh[0]);//seeking GCD, simplifying themm[1] = GCD ( -, mm[0]); thess[1] = GCD ( -, ss[0]); -  in         if(hh[0] % -==0) {//Output theprintf ("%d", hh[0] / -); the         } About         Else   { theprintf ("%d/%d", hh[0]/hh[1], -/hh[1]); the         } the         if(mm[0] % -==0) { +printf ("%d", mm[0] / -); -         } the         Else   {Bayiprintf ("%d/%d", mm[0]/mm[1], -/mm[1]); the         } the         if(ss[0] % -==0) { -printf ("%d \ n", ss[0] / -); -         } the         Else   { theprintf ("%d/%d \ n", ss[0]/ss[1], -/ss[1]); the         } the     } -  the     return 0; the}

Analog Hdoj 5387 Clock

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.