Banner Home Page DIY Contests Problems Ranklist Status Statistics
pdf版的题目下载:初赛goo.gl/rfbDY,决赛goo.gl/fNcyY。K题请使用GUN C++提交,用VC/VC++提交会返回RE。

Nonsensical Encoding

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 167   Accepted Submission(s) : 58

Font: Times New Roman | Verdana | Georgia

Font Size:

Problem Description

  Two fools LiJunLe and beyondxgb are think to be good spies, Because they've invented a foolish kind of encoding.
  This string is encoded with the help of the keyboard of mobile phone. See the picture below. The coding of a letter is the same as what you have pressed on the mobile phone keyboard.
  
  For example, 'a' is encoded into '2', and 'b' is encoded into '22', and e is encoded into '33'.
  In addition, ' '(one space) is encoded into '0', and ',' is encoded into '1', but '#' and '*' will not be changed while being encoded.
  What's more interesting, '2222' is decoded to 'a', and '4444444' is decoded to 'g' and '999999' is decoded to 'x'. But characters '#', '*', '0' and '1' are decoded directly.
  NOTICE: while 'ab' is encoded into '222', it will be decoded into 'c'. That's also why we call this encoding "Fool Encoding".
  Now, give you the encoded string. Your task is to decode it.

Input

  There are multiple test cases. The first line contains an integer T (T<=100), indicating the number of test cases.
  Next T lines follow, one string per line. The length of each string will not exceed 1000. The string only contains number characters('0'~'9'), '#' and '*'.

Output

  For each test case, output "Case #D: " first, D is the index of the test case.
  Then follows the decoding string. Do NOT forget to add a full stop in the end of the decoded string. See the sample output for more details.

Sample Input

2
123456789*###
10222203333044440555506666077777088880999990*0#

Sample Output

Case #1: ,adgjmptw*###.
Case #2: , a d g j m p t w * #.

Source

华南师范大学·2012年ACM程序设计竞赛·决赛

Statistic | Submit | Back