poj 1676 What time is it?

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?

时间: 2024-07-29 07:05:36

poj 1676 What time is it?的相关文章

poj 3635/hdu 1676 Full Tank? 车辆加油+最短路

http://acm.hdu.edu.cn/showproblem.php?pid=1676 给出一张图,n<=1000,m<=10000. 有一辆车想从图的一个地方到达另外一个地方,每个点是一个卖油的地方,每个地方买的有价格不一样,车的最大装油量是c<=100,求初始点到终止点的最小花费. 可以 dp[i][j] 表示走到i点剩余j个单位的汽油时的最小花费,难点在于车需要加油,加多少油,转换问题后发现还是简单的bfs 就是维护一个费用优先队列,每到达一个节点都有两种可扩展的状态,一是加

POJ 3243 Clever Y BSGS

Clever Y Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 6861   Accepted: 1676 Description Little Y finds there is a very interesting formula in mathematics: XY mod Z = K Given X, Y, Z, we all know how to figure out K fast. However, give

ACM训练方案-POJ题目分类

ACM训练方案-POJ题目分类 博客分类: 算法 ACM online Judge 中国: 浙江大学(ZJU):http://acm.zju.edu.cn/ 北京大学(PKU):http://acm.pku.edu.cn/JudgeOnline/ 杭州电子科技大学(HDU):http://acm.hdu.edu.cn/ 中国科技大学(USTC):http://acm.ustc.edu.cn/ 北京航天航空大学(BUAA)http://acm.buaa.edu.cn/oj/index.php 南京

转载:poj题目分类(侵删)

转载:from: POJ:http://blog.csdn.net/qq_28236309/article/details/47818407 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K–0.50K:中短代码:0.51K–1.00K:中等代码量:1.01K–2.00K:长代码:2.01K以上. 短:1147.1163.1922.2211.2215.2229.2232.2234.2242.2245.2262.2301.2309.2313.2334.2346.2348

poj题库分类

初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推.     (5)构造法.(poj3295)     (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996)二.图算法:     (1)图的深度优先遍历和广度优先遍历.     (2)最短路径算法(dijkstra,bellman-ford,floyd,hea

POJ题目(转)

http://www.cnblogs.com/kuangbin/archive/2011/07/29/2120667.html 初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推.     (5)构造法.(poj3295)     (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996)二.图算法:     (

Poj 题目分类

初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推.     (5)构造法.(poj3295)     (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996)二.图算法:     (1)图的深度优先遍历和广度优先遍历.     (2)最短路径算法(dijkstra,bellman-ford,floyd,hea

POJ题目分类(转)

初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推.     (5)构造法.(poj3295)     (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996)二.图算法:     (1)图的深度优先遍历和广度优先遍历.     (2)最短路径算法(dijkstra,bellman-ford,floyd,hea

北大POJ题库使用指南

原文地址:北大POJ题库使用指南 北大ACM题分类主流算法: 1.搜索 //回溯 2.DP(动态规划)//记忆化搜索 3.贪心 4.图论 //最短路径.最小生成树.网络流 5.数论 //组合数学(排列组合).递推关系.质因数法 6.计算几何 //凸壳.同等安置矩形的并的面积与周长.凸包计算问题 8.模拟 9.数据结构 //并查集.堆.树形结构 10.博弈论 11.CD有正气法题目分类: 1. 排序 1423, 1694, 1723, 1727, 1763, 1788, 1828, 1838, 1