题意:给定一个开始时间和一个角度,问你下一个时刻时针和分针形成这个角度是几点。

析:反正数量很小,就可以考虑暴力了,从第一秒开始暴力,直到那个角度即可,不会超时的,数目很少,不过要注意精度。

代码如下:

#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 = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f3f;
const double eps = 1e-8;
const int mod = 360*120;
const int maxn = 2000 + 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 && 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 * 60 + s;
int hh = sum % mod;
int mm = (sum * 12) % mod;
int ans = 0; while(true){
hh = (hh + 1) % mod;
mm = (mm + 12) % mod;
++ans;
if(abs(abs(mm-hh) - t) <= 10) break;
} int sss = (ans + s) % 60;
int mmm = ((ans+s) / 60 + m) % 60;
int hhh = (((ans+s) / 60 + m) / 60 + h) % 12;
printf("Case #%d: %02d:%02d:%02d\n", ++kase, hhh, mmm, sss);
}
return 0;
}
04-06 15:15