HDU6077 思维(水)

来源:互联网 发布:雅马哈网络经销商查询 编辑:程序博客网 时间:2024/06/07 20:04

Time To Get Up

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 407    Accepted Submission(s): 319


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 has5 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 stringt 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..XX..X....X.X....X.X..X......XX.....XX...XX.X..X.X....X....X.X..XX..X.X.........X.X..X.XX...XX.....XX...XX.
 

Sample Output
02:38
 

Source
2017 Multi-University Training Contest - Team 4
比较耗时间的方法:
#include<cstdio>#include<iostream>#include<cstring>#include<string>using namespace std;char str[10][30];char map[10][7][10]={                   {".XX.",                    "X..X","X..X","....","X..X","X..X",".XX.",},{"....", "...X", "...X", "....", "...X", "...X", "....",},{".XX.", "...X", "...X", ".XX.", "X...", "X...", ".XX.",}, {".XX.", "...X", "...X", ".XX.", "...X", "...X", ".XX.",},{"....", "X..X", "X..X", ".XX.", "...X", "...X", "....",},{".XX.", "X...", "X...", ".XX.", "...X", "...X", ".XX.",},{".XX.", "X...", "X...", ".XX.", "X..X", "X..X", ".XX.",},{".XX.", "...X", "...X", "....", "...X", "...X", "....",},{".XX.", "X..X", "X..X", ".XX.", "X..X", "X..X", ".XX.",},{".XX.", "X..X", "X..X", ".XX.", "...X", "...X", ".XX.",}};int get_num(int s){     int i,j,k;      for(k=0;k<10;k++)  {    for(i=0;i<7;i++){for(j=s;j<s+4;j++){if(map[k][i][j-s]!=str[i][j])break;}if(j!=s+4)        break;}if(i==7&&j==s+4){//cout<<k<<endl; return k;}   }}int main(){int t;int h1,h2,m1,m2;scanf("%d",&t);while(t--){for(int i=0;i<7;i++){scanf("%s",str[i]);}        h1=get_num(0);        h2=get_num(5);        m1=get_num(12);        m2=get_num(17);        printf("%d%d:%d%d\n",h1,h2,m1,m2);}} 
找规律特点的便捷的方法:
#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>using namespace std;typedef long long LL;const int MOD = 1e9 + 7;const int MAXN = 5e5 + 10;char str[30][30];int check(int s) {if (str[0][s + 1] == 'X') {if (str[1][s] == 'X') {if (str[1][s + 3] == 'X') {if (str[3][s + 1] == 'X') {if (str[4][s] == 'X') return 8;else return 9;} else {return 0;}} else {if (str[4][s] == 'X') return 6;else return 5;}} else {if (str[4][s] == 'X') return 2;else if (str[3][s+1] == 'X') return 3;else return 7;}} else {if (str[1][s] == 'X') return 4;else return 1;}}int main(){int T;for (scanf("%d", &T); T--; ) {for (int i = 0; i < 7; i++) {scanf("%s", str[i]);}printf("%d%d:%d%d\n", check(0), check(5), check(12), check(17));int h1 = check(0);}return 0;}