Clock
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 860 Accepted Submission(s): 309
Problem Description
Given a time HH:MM:SS and one parameter
a
, you need to calculate next time satisfying following conditions:
1. The angle formed by the hour hand and the minute hand is a .
2. The time may not be a integer(e.g. 12:34:56.78), rounded down(the previous example 12:34:56).
1. The angle formed by the hour hand and the minute hand is a .
2. The time may not be a integer(e.g. 12:34:56.78), rounded down(the previous example 12:34:56).
Input
The input contains multiple test cases.
Each test case contains two lines.
The first line is the time HH:MM:SS (0≤HH<12,0≤MM<60,0≤SS<60) .
The second line contains one integer a(0≤a≤180) .
Each test case contains two lines.
The first line is the time HH:MM:SS (0≤HH<12,0≤MM<60,0≤SS<60) .
The second line contains one integer a(0≤a≤180) .
Output
For each test case, output a single line contains test case number and the answer HH:MM:SS.
Sample Input
0:59:59 30 01:00:00 30
Sample Output
Case #1: 01:00:00 Case #2: 01:10:54
Source
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
#define ll long long
#define ms(a,b) memset(a,b,sizeof(a))
const int M=1e4+10;
int i,j,k,n,m;
int t,h,s;
double eps=1.2*(1e-2);
int main()
{
int T=1;
while(~scanf("%d:%d:%d",&h,&m,&s)){
scanf("%d",&t);
t*=120;
int sum=h*3600+m*60+s;
int hh=sum%(360*120);
int mm=(sum*12)%(360*120);
int ans=0;
while(1){
hh=(hh+1)%(360*120);
mm=(mm+12)%(360*120);
ans++;
if(abs(abs(hh-mm)-t)<=10)break;
}
int anss=(ans+s)%60;
int ansm=((ans+s)/60+m)%60;
int ansh=((((ans+s)/60+m)/60)+h)%12;
printf("Case #%d: %02d:%02d:%02d\n",T++,ansh,ansm,anss);
}
return 0;
}