码迷,mamicode.com
首页 > 其他好文 > 详细

poj 1676 What time is it?

时间:2014-07-06 13:19:09      阅读:300      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   color   数据   art   

Description

An accutron shows time with four digits, from 0000 to 2359. Every digit is represented by 3*3 characters, including ‘|‘s, ‘_‘s and blanks. When the LCD screen works well, the digits look like the following: 
 _     _  _     _  _  _  _  _ 
| | | _| _||_||_ |_ ||_||_|
|_| ||_ _| | _||_| ||_| _|


There are two accutrons at hand. One shows the accurate time, and the other is 15 minutes late. For example, at 8:25am, the first accutron shows ‘0825‘, while the second shows ‘0810‘. 

Unfortunately, there is something wrong with the two LCD screens, namely some parts of the digits missed. Your task is to decide the accurate time, according to the fragmental digits showed on the two accutrons. 

Input

The first line of the input is a single integer t (1 <= t <= 20), the number of test cases. Each case contains three lines, indicating the time on the accurate accutron and the time on the slow accutron, separated by a blank column. (Please refer to the Sample Input.)

Output

For each input, print the accurate time with four digits if it can be ensured, or otherwise the string ‘Not Sure‘.

Sample Input

2
    _  _  _      _     _ 
  | _  _||       _   ||  
  | _ |_   |   | _    |_|
    _  _  _   _  _     _ 
  ||_  _||       _|  ||  
  | _ |_   |   ||     |_|

Sample Output

Not Sure
0825
题意:一块电子表的液晶屏坏了,根据显示的字符判断前面输入的时间减去15分钟是否等于后面的时间,如果结果唯一输出前面的时间,否则就输出“Not Sure”。
思路:暴力;
具体:把0-9这10个数字转换成一维数组,与输入的作对比。
注意:测试数据“0000 2345”,“ _  _     _   _  _  _  _ ”
| ||_|  || | | |  ||_ |_ 
|_||_|  ||_| |_|  | _| _|。
ac代码:
  1 #include<stdio.h>
  2 #include<string.h>
  3 #include<stdlib.h>
  4 int s1[10][9]= {{0,1,0,1,0,1,1,1,1},{0,0,0,0,0,1,0,0,1},{0,1,0,0,1,1,1,1,0},{0,1,0,0,1,1,0,1,1},{0,0,0,1,1,1,0,0,1},{0,1,0,1,1,0,0,1,1},{0,1,0,1,1,0,1,1,1},{0,1,0,0,0,1,0,0,1},{0,1,0,1,1,1,1,1,1},{0,1,0,1,1,1,0,1,1}};
  5 int main()
  6 {
  7     int a,b,c,d,e,f,g,h,i,j,l,l1,n,vis[150],vis1[150],vis2[150],vis3[150],vis4[150],vis5[150],vis6[150],vis7[150];
  8     int x1[150],x2[150],x3[150],x4[150],x5[150],x6[150],x7[150],x8[10000],x9[15000],x[150],a1,a2,a3,a4,a5,a6,a7,a8,a9,a0,b1,b2,b3,b4,b5;
  9     int y1[15000],y2[15000],y3[15000],y4[10500];
 10     scanf("%d",&n);
 11 getchar();
 12     char s[150][100];
 13     while(n--)
 14     {
 15         a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,a1=0,a2=0,a3=0,a4=0,a5=0,a6=0,a7=0,a8=0,a9=1,a0=0,b1=0,b2=0,b3=0,b4=0,b5=0,l=0,l1=0;
 16         for(i=0;i<3;i++)
 17          gets(s[i]);
 18         for(i=0; i<3; i++)
 19         {
 20             for(j=0; j<3; j++)
 21             {
 22                 if(s[i][j]== )
 23                     vis[a++]=0;
 24                 else
 25                     vis[a++]=1;
 26             }
 27             for(j=3; j<6; j++)
 28             {
 29                 if(s[i][j]== )
 30                     vis1[b++]=0;
 31                 else
 32                     vis1[b++]=1;
 33             }
 34             for(j=6; j<9; j++)
 35             {
 36                 if(s[i][j]== )
 37                     vis2[c++]=0;
 38                 else
 39                     vis2[c++]=1;
 40             }
 41             for(j=9; j<12; j++)
 42             {
 43                 if(s[i][j]== )
 44                     vis3[d++]=0;
 45                 else
 46                     vis3[d++]=1;
 47             }
 48             for(j=13; j<16; j++)
 49             {
 50                 if(s[i][j]== )
 51                     vis4[e++]=0;
 52                 else
 53                     vis4[e++]=1;
 54             }
 55             for(j=16; j<19; j++)
 56             {
 57                 if(s[i][j]== )
 58                     vis5[f++]=0;
 59                 else
 60                     vis5[f++]=1;
 61             }
 62             for(j=19; j<22; j++)
 63             {
 64                 if(s[i][j]== )
 65                     vis6[g++]=0;
 66                 else
 67                     vis6[g++]=1;
 68             }
 69             for(j=22; j<25; j++)
 70             {
 71                 if(s[i][j]== )
 72                     vis7[h++]=0;
 73                 else
 74                     vis7[h++]=1;
 75             }
 76         }
 77         for(i=0; i<10; i++)
 78         {
 79             a9=0;
 80             for(j=0; j<10; j++)
 81             {
 82                 a9++;
 83                 if(vis[j]>s1[i][j])
 84                 {
 85                     a9=0;
 86                     break;
 87                 }
 88                 if(a9==9)
 89                     x[a0++]=i;
 90             }
 91         }
 92         for(i=0; i<10; i++)
 93         {
 94             a9=0;
 95             for(j=0; j<10; j++)
 96             {
 97                 a9++;
 98                 if(vis1[j]>s1[i][j])
 99                 {
100                     a9=0;
101                     break;
102                 }
103                 if(a9==9)
104                     x1[a1++]=i;
105             }
106         }
107         for(i=0; i<10; i++)
108         {
109             a9=0;
110             for(j=0; j<10; j++)
111             {
112                 a9++;
113                 if(vis2[j]>s1[i][j])
114                 {
115                     a9=0;
116                     break;
117                 }
118                 if(a9==9)
119                     x2[a2++]=i;
120             }
121         }
122         for(i=0; i<10; i++)
123         {
124             a9=0;
125             for(j=0; j<10; j++)
126             {
127                 a9++;
128                 if(vis3[j]>s1[i][j])
129                 {
130                     a9=0;
131                     break;
132                 }
133                 if(a9==9)
134                     x3[a3++]=i;
135             }
136         }
137         for(i=0; i<10; i++)
138         {
139             a9=0;
140             for(j=0; j<10; j++)
141             {
142                 a9++;
143                 if(vis4[j]>s1[i][j])
144                 {
145                     a9=0;
146                     break;
147                 }
148                 if(a9==9)
149                     x4[a4++]=i;
150             }
151         }
152         for(i=0; i<10; i++)
153         {
154             a9=0;
155             for(j=0; j<10; j++)
156             {
157                 a9++;
158                 if(vis5[j]>s1[i][j])
159                 {
160                     a9=0;
161                     break;
162                 }
163                 if(a9==9)
164                     x5[a5++]=i;
165             }
166         }
167         for(i=0; i<10; i++)
168         {
169             a9=0;
170             for(j=0; j<10; j++)
171             {
172                 a9++;
173                 if(vis6[j]>s1[i][j])
174                 {
175                     a9=0;
176                     break;
177                 }
178                 if(a9==9)
179                     x6[a6++]=i;
180             }
181         }
182         for(i=0; i<10; i++)
183         {
184             a9=0;
185             for(j=0; j<10; j++)
186             {
187                 a9++;
188                 if(vis7[j]>s1[i][j])
189                 {
190                     a9=0;
191                     break;
192                 }
193                 if(a9==9)
194                     x7[a7++]=i;
195             }
196         }
197         for(i=0; i<a0; i++)
198         {
199             for(j=0; j<a1; j++)
200                 if((x[i]*1000+x1[j]*100)<2400)
201                 {
202                     x8[a8++]=x[i]*1000+x1[j]*100;
203                 }
204         }
205         for(i=0; i<a4; i++)
206         {
207             for(j=0; j<a5; j++)
208                 if((x4[i]*1000+x5[j]*100)<2400)
209                 {
210                     x9[b1++]=x4[i]*1000+x5[j]*100;
211                 }
212         }
213         for(i=0; i<a2; i++)
214         {
215             for(j=0; j<a3; j++)
216                 if((x2[i]*10+x3[j])<60)
217                 {
218                     y1[b2++]=x2[i]*10+x3[j];
219                 }
220         }
221         for(i=0; i<a6; i++)
222         {
223             for(j=0; j<a7; j++)
224                 if((x6[i]*10+x7[j])<60)
225                 {
226                     y2[b3++]=x6[i]*10+x7[j];
227                 }
228         }
229         for(i=0; i<a8; i++)
230             for(j=0; j<b2; j++)
231             {
232                 y3[b4++]=x8[i]+y1[j];
233             }
234         for(i=0; i<b1; i++)
235             for(j=0; j<b3; j++)
236             {
237                 y4[b5++]=x9[i]+y2[j];
238             }
239             int num=0,sum=0;
240         for(i=0; i<b4; i++)
241         {
242             for(j=0; j<b5; j++)
243             {
244                 sum=y3[i];
245                  num=y3[i]%100;
246                  if(sum<15)
247                  {
248                      sum+=2400;
249                  }
250                 if(num<15)
251                 {
252                     sum=sum-40;
253                 }
254                 num=sum-15;
255                 if(num==y4[j])
256                 {
257                     l++;
258                     l1=y3[i];
259                 }
260             }
261         }
262         if(l==1)
263             printf("%04d\n",l1);
264         else
265             printf("Not Sure\n");
266     }
267 }

 

poj 1676 What time is it?,布布扣,bubuko.com

poj 1676 What time is it?

标签:des   style   blog   color   数据   art   

原文地址:http://www.cnblogs.com/Xacm/p/3825831.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!