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)