hdu4287map应用

#include <iostream>
#include <cstdio>
#include <map>
#include <cstring>
#include <math.h>
using namespace std;
char b[6];
int aa[5050];
char mp[512];
int tonum(char b[])
{
    int ret=0;
    for(int i=0;b[i]!='\0';i++)
        ret=ret*10+mp[b[i]];
    return ret;
}
int main()
{

    mp['a']=2,mp['b']=2,mp['c']=2;
    mp['d']=3,mp['e']=3,mp['f']=3;
    mp['g']=4,mp['h']=4,mp['i']=4;
    mp['j']=5,mp['k']=5,mp['l']=5;
    mp['m']=6,mp['n']=6,mp['o']=6;
    mp['p']=7,mp['q']=7,mp['r']=7,mp['s']=7;
    mp['t']=8,mp['u']=8,mp['v']=8;
    mp['w']=9,mp['x']=9,mp['y']=9,mp['z']=9;
    int t,n,m,i,j,ans,bb;

    scanf("%d",&t);
    while(t--)
    {
        map<int,int> mm;
        map<int,int>::iterator it;
        scanf("%d%d",&n,&m);
        for(i=0;i<n;i++)
            scanf("%d",&aa[i]);
        for(i=0;i<m;i++)
        {
            scanf("%s",b);
            bb=tonum(b);
            it=mm.find(bb);
            if(it!=mm.end())
                mm[bb]++;
            else
                mm[bb]=1;
        }
        for(i=0;i<n;i++)
        {
            printf("%d\n",mm[aa[i]]);
        }

    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值