杭电 Time To Get Up
来源:互联网 发布:二手淘宝网店出售 编辑:程序博客网 时间:2024/05/16 09:46
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.
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(1≤T≤1440) , denoting the number of test cases.
In each test case, there is an7×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.
In each test case, there is an
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:00≤t≤23: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
题意:输入7 X 21的字符串,输出时间
分析:直接模拟啊,0-20列,第4 9 10 11 16 列都不是有效的列,剩下的16列表示4个数,并且都是连续的,每一个7 X 4都判断一次,看看是什么数,输出即可
AC代码如下:
#include <iostream>#include <cstdio>#include <cstring>#include <string>using namespace std;char a[10][25];char ch[7][4];int fun(char c[7][4])//利用数形状的差距直接判断{ for(int i=0;i<7;i++) for(int j=0;j<4;j++) { if(c[3][1]=='X' && c[3][2]=='X') { if(c[0][1]=='.' && c[0][2]=='.') return 4; if(c[4][0]=='X' && c[5][0]=='X') { if(c[1][0]=='.' && c[2][0]=='.') return 2; if(c[1][3]=='X' && c[2][3]=='X') return 8; return 6; } else { if(c[1][3]=='.' && c[2][3]=='.') return 5; if(c[1][0]=='.' && c[2][0]=='.') return 3; return 9; } } else if(c[3][1]=='.' && c[3][2]=='.') { if(c[1][0]=='X' && c[2][0]=='X') return 0; if(c[0][1]=='X' && c[0][2]=='X') return 7; return 1; } } return -1;}int main(){ int t; cin>>t; getchar(); while(t--) { for(int i=0;i<7;i++) scanf("%s",a[i]); int num=0; int coun=0; for(int j=0;j<21;j++) { if(j==4 || j==9 || j==10 || j==11 || j==16) { continue; } else { num++; } if(num%4==0)//累计四行做一次判断 { for(int i=0;i<7;i++) { for(int k=j-3,s=0;k<=j;k++,s++) { ch[i][s]=a[i][k]; } } cout<<fun(ch); coun++; if(coun==2) cout<<":"; } } cout<<endl; } return 0;}
阅读全文
0 0
- 杭电 Time To Get Up
- Time To Get Up
- Time To Get Up
- Time To Get Up
- Time To Get Up
- 杭电暑期多校集训—Time To Get Up
- HDU6077-Time To Get Up
- Time To Get Up HDU
- HDU6077-Time To Get Up
- hdu6077 Time To Get Up
- 2017多校四 1011题 hdu 6077 Time To Get Up 感谢数电老师(。
- hdu-暑假集训-Time To Get Up
- hdu 6077-Time To Get Up
- HDU 6077 Time To Get Up 模拟
- HDU 6077 Time To Get Up【】
- HDU 6077 Time To Get Up
- hdu 6077 Time To Get Up【暴力】
- hdu 6077 Time To Get Up
- Linux设置服务开机启动
- hud 一个人的旅行 (Dijkstra)
- 算法编程题3-字符串旋转词问题
- Dual licensed under the MIT and GPL licenses 遇到MIT 和 GPL都有情况怎么算
- mac上开启php环境(非vim)
- 杭电 Time To Get Up
- java 注解annotation(二)
- Linux常用命令
- 不懂GPU深度学习,何以谈人工智能?
- XSS编码初析
- manacher算法小计
- MYEclipse 安装svn
- (新零售)商户网格化运营
- 【SSD】SSD caffe编译不通过