HDU 5705 Clock (Precision control, violence)

Source: Internet
Author: User

Test instructions: Given a start time and an angle, ask you the next moment the hour and minute hand form this angle is a few points.

Analysis: Anyway the number is very small, you can consider violence, starting from the first second violence, until that angle can, will not time out, the number is few, but pay attention to precision.

The code is as follows:

#include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream > #include <cstring> #include <set> #include <queue> #include <algorithm> #include <vector > #include <map>using namespace std; typedef long Long Ll;typedef pair<int, int> p;const int INF = 0x3f3f3f3 F;const Double inf = 0x3f3f3f3f3f3f3f;const double eps = 1e-8;const int mod = 360*120;const int maxn = + 5;const int Dr[] = {0, 0,-1, 1};const int dc[] = {-1, 1, 0, 0};int N, m;inline bool is_in (int r, int c) {return R >= 0 &&am P R < n && C < m && c >= 0;}    int main () {int h, m, S, t, Kase = 0;        while (scanf ("%d:%d:%d", &h, &m, &s) = = 3) {scanf ("%d", &t);        T *= 120;        int sum = h * 3600 + M * + S;        int hh = sum% mod;        int mm = (sum *)% MoD;        int ans = 0;            while (true) {hh = (hh + 1)% MoD;   MM = (mm + +)% MoD;         ++ans;        if (ABS (MM-HH)-T) <= break;        } int sss = (ans + s)% 60;        int mmm = ((ans+s)/+ m)% 60;        int HHH = (((ans+s)/+ M)/+ h)% 12;    printf ("Case #%d:%02d:%02d:%02d\n", ++kase, HHH, MMM, SSS); } return 0;}

HDU 5705 Clock (Precision control, violence)

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.