• HDU 5705 Clock(模拟,分类讨论)


    Clock

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)
    Total Submission(s): 500    Accepted Submission(s): 176


    Problem Description
    Given a time HH:MM:SS and one parameter , you need to calculate next time satisfying following conditions:

    1. The angle formed by the hour hand and the minute hand is .
    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.
    The second line contains one integer .
     
    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

    题意:给定一个时间作为起点,然后求下一个时针和分针的角度相差为k的时间。

    【题意】
    时间为12小时制。
    告诉你一个时刻,让你输出在这个时刻之后的下一个时刻,
    满足:该时刻,时针分针掐好相差某个的角度为a。
    (注意,满足要求的时刻不一定是恰好以秒为单位,可以是秒与秒之间的时刻,我们可以向下取整)

    【类型】
    追及问题,判断

    #include<stdio.h>
    #include<string.h>
    #include<stdio.h>  
    #include<string.h>  
    #include<stdlib.h>  
    #include<queue>  
    #include<stack>  
    #include<math.h>  
    #include<vector>  
    #include<map>  
    #include<set>  
    #include<cmath>  
    #include<complex>  
    #include<string>  
    #include<algorithm>  
    #include<iostream>  
    #include<string.h>
    #include<algorithm>
    #include<vector>
    #include<stdio.h>
    #include<cstdio>
    #include<time.h>
    #include<stack>
    #include<queue>
    #include<deque>
    #include<map>
    #define inf 0x3f3f3f3f
    #define ll long long
    using namespace std;
    int main()
    {
        double h,m,s;
        char pp;
        int k=0;
        while(cin>>h>>pp>>m>>pp>>s)
        {
            k++;
            int a;
            cin>>a;
            double ah=h*30+m*0.5+s/120.0;
            while(ah>=360) ah-=360;
            double am=m*6+s/10.0;
            double x;
            if(am>=ah)
            {
                if(am-ah<=360-am+ah)
                {
                    double o=am-ah;
                    if(a>o) x=a-o;
                    else x=360-o-a;
                }
                else
                {
                    double o=360-am+ah;
                    if(a>=o) x=o+a;
                    else x=o-a;
                }
            }
            else
            {
                if(ah-am<=360-ah+am)
                {
                    double  o=ah-am;
                    if(a<o) x=o-a;
                    else x=a+o;
                }
                else
                {
                    double o=360-ah+am;
                    if(a>o) x=a-o;
                    else x=360-a-o;
                }
            }
    
            x=x*120/11;
            int ss=(int)(s+x);
            int y=0;
            if(ss>=60)
            {
                y=ss/60;
                ss=ss%60;
            }
            int mm=m+y;
            y=0;
            if(mm>=60)
            {
                y=mm/60;
                mm=mm%60;
            }
            int hh=h+y;
            y=0;
            if(hh>=12)
            {
                hh=hh%12;
            }
            cout<<"Case #"<<k<<": ";
            printf("%02d:%02d:%02d
    ",hh,mm,ss);
        }
        return 0;
    }
  • 相关阅读:
    git删除远程tag
    date的getTime问题
    EasyExcel读取excel文件反射成实体后全为NULL
    springboot回滚部分异常
    Java8 LocalDate、Date、LocalDateTime、时间戳的转换
    mysql未查到行,返回一条默认结果
    Maven No archetype found in remote catalog. Defaulting to internal catalog.
    HashMap相关资料
    HibernateHql
    用户名登录
  • 原文地址:https://www.cnblogs.com/caiyishuai/p/13271012.html
Copyright © 2020-2023  润新知