南邮 OJ 1464 Text Messaging
来源:互联网 发布:什么软件可以泡妞 编辑:程序博客网 时间:2024/06/08 03:46
Text Messaging
总提交 : 65 测试通过 : 38
比赛描述
You can type alphabets on a cell phone using numeric keypads using the following key mapping.
Numbers
Alphabets
2
abc
3
def
4
ghi
5
jkl
Numbers
Alphabets
6
mno
7
pqrs
8
tuv
9
wxyz
Since one numeric keypad represents many alphabets, on the standard system, the user must press the keypad many times to choose the right alphabet. For example to type the word “rat”, the user must press 77728. (777 to get “r”, 2 to get “a”, and 8 to get “t”.)
After the word prediction software, the user does not have to do that anymore. To type “rat” the user can type 728, and the prediction software would guess “rat” automatically. For another example, consider the word “cat.” To type that the user needs only press 228. We call the key sequence required to type a given word as its key sequence. Thus, the key sequence of “cat” is 228, and the key sequence of “rat” is 728.
However, this is not perfect because many words share the same key sequence. For example, “cat” and “bat” have the same key sequence 228.
Given a set of words, your task is to find out how many different key sequences needed to type any words in the set. For example if the set is {“rat”, “cat”, “bat”}, the number of different key sequences is 2, i.e., 228 and 728.
输入
The first line of the input contains an integer T (1 <= T <= 6) denoting the number of test cases. After that T test cases follow.
The first line of each test case contains an integer N (1 <= N <= 1,000) denoting the number of words. After that N lines follows. Each line contains different word. Each word consists of only small English alphabets, and the maximum length of any words is at most 20 characters.
输出
For any test case, your program should output an integer K denoting the number of different key sequences.
样例输入
2
3
cat
rat
bat
5
abcdefg
cccdddi
aaafefh
hello
world
样例输出
2
3
提示
In the first case, two sequences are 228 and 728. In the second case, the three sequences are 2223334, 43556, and 96753.
用于NUPT ACM 2010 Personal Ranking Contest 5
题目来源
ACM-ICPC Thailand Southern Area Programming Contest 2010
#include<iostream>#include<string>#include<set>using namespace std;int main(){int a[26]={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};string s;int T,N,i,len;set<string> sSet;cin>>T;while(T--){sSet.clear();cin>>N;while(N--){cin>>s;len = (int)s.length();for(i=0; i<len; i++){s[i] = a[s[i]-'a'];}sSet.insert(s);}cout<<sSet.size()<<endl;}}
- 南邮 OJ 1464 Text Messaging
- UVALive 4236 Text Messaging Improvement?
- Sicily 1627. Text Messaging Improvement?
- Messaging
- Messaging
- Messaging
- Messaging
- LeetCode OJ:Text Justification
- LeetCode OJ - Text Justification
- LeetCode OJ Text Justification
- HDU oj Text Reverse
- OJ---text reverse 字符串问题
- hdu oj 1062 Text Reverse(字符串)
- sublime text配置刷oj模板
- Windows Messaging
- Delayed Messaging
- web messaging
- HTML5 Messaging
- UIButton和UITextfield
- JAVA基础一大堆0805线程
- 为何大多数人做出来的图表只是一坨屎?
- Python编译器实现内幕:添加一个新语句
- 文件服务器
- 南邮 OJ 1464 Text Messaging
- JavaScript权威指南_149_第15章_脚本化文档_15.10-其他文档特性-可编辑的内容
- 软件工程师职场生存技能
- UI04_Delegate
- 登陆界面的完善
- 利用Mono.Cecil动态修改程序集来破解商业组件
- MVC框架介绍
- 南邮 OJ 1469 求和
- 【OC06】类目、延展、协议、计时器(连载八)