hdu 4287 Intelligent IME map的应用
2012-09-11 23:47
106 查看
http://acm.hdu.edu.cn/showproblem.php?pid=4287
题意:
给出n个手机数字序列,m个英文组合,求每个数字序列对应的可能的英文组合在下边的出现了多少个。
思路:
才开始想复杂了,其实只要用一个map即可。
View Code
题意:
给出n个手机数字序列,m个英文组合,求每个数字序列对应的可能的英文组合在下边的出现了多少个。
思路:
才开始想复杂了,其实只要用一个map即可。
View Code
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <queue> #include <stack> #include <set> #include <map> #include <string> #define CL(a,num) memset((a),(num),sizeof(a)) #define iabs(x) ((x) > 0 ? (x) : -(x)) #define Min(a,b) (a) > (b)? (b):(a) #define Max(a,b) (a) > (b)? (a):(b) #define ll long long #define inf 0x7f7f7f7f #define MOD 100000007 #define lc l,m,rt<<1 #define rc m + 1,r,rt<<1|1 #define pi acos(-1.0) #define test puts("<------------------->") #define maxn 100007 #define M 100007 #define N 50007 using namespace std; //freopen("din.txt","r",stdin); int a ; map<int,int>mp; int n,m; int find(char *s){ int i; int len = strlen(s); int num = 0; for (i = 0; i < len; ++i){ if (s[i] == 'a' || s[i] == 'b' || s[i] == 'c') num = num*10 + 2; if (s[i] == 'd' || s[i] == 'e' || s[i] == 'f') num = num*10 + 3; if (s[i] == 'g' || s[i] == 'h' || s[i] == 'i') num = num*10 + 4; if (s[i] == 'j' || s[i] == 'k' || s[i] == 'l') num = num*10 + 5; if (s[i] == 'm' || s[i] == 'n' || s[i] == 'o') num = num*10 + 6; if (s[i] == 'p' || s[i] == 'q' || s[i] == 'r' || s[i] == 's') num = num*10 + 7; if (s[i] == 't' || s[i] == 'u' || s[i] == 'v') num = num*10 + 8; if (s[i] == 'w' || s[i] == 'x' || s[i] == 'y' || s[i] == 'z') num = num*10 + 9; } return num; } int main(){ //freopen("din.txt","r",stdin); int i,t; char str[10]; scanf("%d",&t); while (t--){ scanf("%d%d",&n,&m); for (i = 0; i < n; ++i) scanf("%d",&a[i]); mp.clear(); for (i = 0; i < m; ++i){ scanf("%s",str); int x = find(str); mp[x]++; } for (i = 0; i < n; ++i){ printf("%d\n",mp[a[i]]); } } return 0; }
相关文章推荐
- Trie字典树应用HDU--1251
- HDU1232 畅通工程---(经典并查集应用)
- HDU 1870 愚人节的礼物(栈的简单应用)
- hdu 3325 Arithmetically Challenged(dfs全排+暴力枚举破解+set集合的应用)
- hdu_1222_欧几里得_gcd简单应用_欧几里得扩展性质
- HDU 1232畅通工程(并查集经典应用)
- (step4.1.4)hdu 2178(猜数字——逆向应用二分法)
- hdu 4941 Magical Forest(STL之map应用)2014多校训练第7场
- Match:Cyclic Nacklace(KMP的next数组的高级应用)(HDU 3746)
- HDU 1022 (栈的基本应用)
- 动态规划dp(简单应用)hdu 2151 Worm(石头)
- 【KMP应用】HDU 1711
- HDU 4841:圆桌问题(vector应用)
- hdu-1171Big Event in HDU(dp的应用)
- hdu 5514 (欧拉函数的应用)
- hdu 3038 How Many Answers Are Wrong【并查集的简单应用】
- HDU 1082.Matrix Chain Multiplication【栈的应用+矩阵乘法规则】【1月4】
- hdu 1848【博弈】sg函数应用
- hdu 1251 字典树的应用
- HDU 4268 Alice and Bob 贪心+set应用