Intelligent IME

手机那种拼音的智能输入,给出一个字典,里面有一些单词,然后给出一些按键顺序,要求是看按出的字母组合有多少是存在于字典中的,反着来看就容易多了,用一个数组来记录字典里面每个单词的按键便可以与开始的数字代表的按键顺序对应,记录次数便可以出解。

#include
#include
#include

using namespace std;

int hash[1000000];
int main(){
    char s[200],str[10];
    int query[5005]; 
    s['a']=s['b']=s['c']=2;
    s['d']=s['e']=s['f']=3;
    s['g']=s['h']=s['i']=4;
    s['j']=s['k']=s['l']=5;
    s['m']=s['n']=s['o']=6;
    s['p']=s['q']=s['r']=s['s']=7;
    s['t']=s['u']=s['v']=8;
    s['w']=s['x']=s['y']=s['z']=9;
    
    int n,m,t;
    scanf("%d",&t);
    while(t--){
         memset(hash,0,sizeof(hash));
         scanf("%d %d",&n,&m);
         for(int i=0;i


你可能感兴趣的:(字符串,数学)