2016女生赛 1004 Clock【】

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).

 

Input
The input contains multiple test cases.

Each test case contains two lines.
The first line is the time HH:MM:SS (0HH<12,0MM<60,0SS<60) .
The second line contains one integer  a(0a180) .
 

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;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值