(?? ' Ω´? Smart phones

Source: Internet
Author: User

(?? ' Ω´? Smartphone timelimit:2000/1000 MS (java/others) menorylimit:32768/32768 K (java/others) 64-bit integer IO format:%i64dProblem description in everyone has a cell phone today. We must be familiar with the smart English input method on the phone. Specifically, the number buttons can correspond to the English alphabet as follows:
2:a, B, C 3:d, E, F 4:g, H, I 5:j, K, L 6:M, N, O
7:p, Q, R, S 8:t, u, v 9:w, x, Y, Z
When we want to enter the string "Ming", we need to press the number key 9, 4, 6, 4, and then the IME will be selected in the phone dictionary, all the words that match pinyin.
Now, here's the question, give you the key sequence of the N-group number keys, and the M-group string, depending on the key sequence of the number keys of each group, you can put together how many words, input the first line of T, indicate a T group test case, each set of test cases according to the following actions:
The first line inputs two integers r n (1 <= n <= 5000), and M (1 <= m <= 5000), which indicates the key sequence and M-group string with N sets of numeric keys.
Next there are n rows, each line entering a number not exceeding 6 digits, representing a set of key sequences.
Then there are m rows, each line entering a string of no more than 6 characters. Output Each set of test cases, according to the order of the keys given, in M-string, statistics can form how many matching strings, sampleinput
4466444874hooightmihgtgo
Sampleoutput
220

Code (Map it out, simple hash):
1#include <stdio.h>2#include <algorithm>3#include <string.h>4 using namespacestd;5 #defineMax 10086116 intSign[max];7 intto[ -]={2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9};8 intDeal (Charstr[])9 {Ten     inti,sum=0, len=strlen (str); One      for(i=0; i<len;i++) A     { -sum=sum*Ten+to[str[i]-'a']; -     } the     returnSum; - } - intMain () - { +     intt,n,m,i,j; -     intnum[5117]; +     Charstr[5117]; Ascanf"%d",&T); at      while(t--) -     { -memset (sign,0,sizeof(sign)); -scanf"%d%d",&n,&M); -          for(i=0; i<n;i++) -         { inscanf"%d",&num[i]); -         } to          for(i=0; i<m;i++) +         { -scanf"%s", Str); theSign[deal (STR)]++; *         } $          for(i=0; i<n;i++)Panax Notoginseng         { -printf"%d\n", Sign[num[i]]); the         } +     } A     return 0; the}
View Code

(?? ' Ω´? Smart phones

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.