zoukankan      html  css  js  c++  java
  • HDU 6077 17多校4 Time To Get Up 水题

    Problem Description
    Little Q's clock is alarming! It's time to get up now! However, after reading the time on the clock, Little Q lies down and starts sleeping again. Well, he has 5 alarms, and it's just the first one, he can continue sleeping for a while.

    Little Q's clock uses a standard 7-segment LCD display for all digits, plus two small segments for the '':'', and shows all times in a 24-hour format. The '':'' segments are on at all times.



    Your job is to help Little Q read the time shown on his clock.
     
    Input
    The first line of the input contains an integer T(1T1440), denoting the number of test cases.

    In each test case, there is an 7×21 ASCII image of the clock screen.

    All digit segments are represented by two characters, and each colon segment is represented by one character. The character ''X'' indicates a segment that is on while ''.'' indicates anything else. See the sample input for details.
     
    Output
    For each test case, print a single line containing a string t in the format of HH:MM, where t(00:00t23:59), denoting the time shown on the clock.
     
    Sample Input
    1
    .XX...XX.....XX...XX.
    X..X....X......X.X..X
    X..X....X.X....X.X..X
    ......XX.....XX...XX.
    X..X.X....X....X.X..X
    X..X.X.........X.X..X
    .XX...XX.....XX...XX.
     
    Sample Output
    02:38

    题意:把字符串翻译成时间。

    题解:直接利用他们的区别判断即可。

     1 #include <iostream>
     2 #include<cstdio>
     3 #include<algorithm>
     4 #include<queue>
     5 #include<map>
     6 #include<vector>
     7 #include<cmath>
     8 #include<cstring>
     9 using namespace std;
    10 
    11 char time[7+1][21+1];
    12 int check(int i)
    13 {
    14     int j;
    15     if(time[6][i]=='X')
    16     {
    17         if(time[4][i+1]=='.')
    18             return 0;
    19         else if(time[2][i]=='.')
    20             return 2;
    21         else if(time[2][i+3]=='.')
    22             return 6;
    23         else
    24             return 8;
    25     }
    26     else
    27     {
    28         if(time[2][i]=='X')
    29         {
    30             if(time[1][i+1]=='X')
    31             {
    32                 if(time[2][i+3]=='X')
    33                     return 9;
    34                 else
    35                     return 5;
    36             }
    37             else
    38                 return 4;
    39         }
    40         else
    41         {
    42             if(time[4][i+1]=='.')
    43             {
    44                 if(time[1][i+1]=='X')
    45                     return 7;
    46                 else
    47                     return 1;
    48             }
    49             else
    50                 return 3;
    51         }
    52     }
    53 }
    54 
    55 int main()
    56 {
    57     int a,b,c,d;
    58     int T;
    59     scanf("%d",&T);
    60     while(T--)
    61     {
    62         for(int i=1;i<=7;i++)
    63             for(int j=1;j<=21;j++)
    64                 cin>>time[i][j];
    65         a=check(1);
    66         b=check(6);
    67         c=check(13);
    68         d=check(18);
    69         printf("%d%d:%d%d
    ",a,b,c,d);
    70     }
    71     return 0;
    72 }
  • 相关阅读:
    《算法竞赛入门经典》(刘汝佳)——排序与检索(基础)
    Python中的GIL
    MongoDB 安装
    python3 报错集合
    socket 实例化方法
    socket入门
    Day_6作业_模拟人生
    高阶函数举例
    面向对象_python
    xml
  • 原文地址:https://www.cnblogs.com/Annetree/p/7289355.html
Copyright © 2011-2022 走看看