ACM题目:487-3279

题目是这样子的

Description

Businesses like to have memorable telephone numbers. One way to make a telephone number memorable is to have it spell a memorable word or phrase. For example, you can call the University of Waterloo by dialing the memorable TUT-GLOP. Sometimes only part of the number is used to spell a word. When you get back to your hotel tonight you can order a pizza from Gino‘s by dialing 310-GINO. Another way to make a telephone number memorable is to group the digits in a memorable way. You could order your pizza from Pizza Hut by calling their ``three tens‘‘ number 3-10-10-10.

The standard form of a telephone number is seven decimal digits with a hyphen between the third and fourth digits (e.g. 888-1200). The keypad of a phone supplies the mapping of letters to numbers, as follows:

A, B, and C map to 2 
D, E, and F map to 3 
G, H, and I map to 4 
J, K, and L map to 5 
M, N, and O map to 6 
P, R, and S map to 7 
T, U, and V map to 8 
W, X, and Y map to 9

There is no mapping for Q or Z. Hyphens are not dialed, and can be added and removed as necessary. The standard form of TUT-GLOP is 888-4567, the standard form of 310-GINO is 310-4466, and the standard form of 3-10-10-10 is 310-1010.

Two telephone numbers are equivalent if they have the same standard form. (They dial the same number.)

Your company is compiling a directory of telephone numbers from local businesses. As part of the quality control process you want to check that no two (or more) businesses in the directory have the same telephone number.

Input

The input will consist of one case. The first line of the input specifies the number of telephone numbers in the directory (up to 100,000) as a positive integer alone on the line. The remaining lines list the telephone numbers in the directory, with each number alone on a line. Each telephone number consists of a string composed of decimal digits, uppercase letters (excluding Q and Z) and hyphens. Exactly seven of the characters in the string will be digits or letters.

Output

Generate a line of output for each telephone number that appears more than once in any form. The line should give the telephone number in standard form, followed by a space, followed by the number of times the telephone number appears in the directory. Arrange the output lines by telephone number in ascending lexicographical order. If there are no duplicates in the input print the line:

No duplicates.

Sample Input

12
4873279
ITS-EASY
888-4567
3-10-10-10
888-GLOP
TUT-GLOP
967-11-11
310-GINO
F101010
888-1200
-4-8-7-3-2-7-9-
487-3279

Sample Output

310-1010 2
487-3279 4
888-4567 3

下面先给出解决思路1. vector<string>类型的数据结构存储输入的原始号码2. 函数vector<int> ConvertToNeatNumbers(const vector<string>)处理得到的字符串,得到纯净的数字号码3. 比较区别4. 输出结果
时间: 2024-10-13 14:25:22

ACM题目:487-3279的相关文章

杭电ACM题目分类

杭电ACM题目分类 基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028. 1029.1032.1037.1040.1048.1056.1058.1061.1070.1076.1089.1090.1091.1092. 1093.1094.1095.1096.1097.1098.1106.1108.1157.1163.1164.1170.1194.1196. 1197.1201.1202.1205.1219.1234.123

超强的ACM题目类型总结

转:初期: 一.基本算法:       (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.       (4)递推.       (5)构造法.(poj3295)     (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996) 二.图算法:       (1)图的深度优先遍历和广度优先遍历.       (2)最短路径算法(dijkstra,bellman-

我的ACM题目测试数据产生方法

到网上搜了下ACM题目产生方法,却没有搜索到有用的资料,那只能自己钻研一下了,下面把钻研出的结果给大家分享一下. 我们知道,ACM的题目对算法要求很高,OJ上而如何评判一个算法的复杂度靠的是测试数据.一般地,题目需要数据量比较大,不可能人工地去产生,只能借助计算机产生测试数据,而为了避免数据出现规律性,那应该尽量让数据随机.接下来,我们就研究最一般的问题,如何产生int,long long ,大整数,以及字符串? 我们知道,C语言提供了我们一个随机函数rand(),可惜的是它只能产生(1~2^1

ACM题目-Who&#39;s in the Middle

#这题主要用到了sort函数去简化排序的过程(需要声明#include <algorithm>) 描述 FJ is surveying his herd to find the most average cow. He wants to know how much milk this 'median' cow gives: half of the cows give as much or more than the median; half give as much or less. Give

HDOJ ACM题目分类

模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 1106 1107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 1197 1200 1201 120

有一种acm题目叫做,奇葩!

本文全然没有技术含量,纯粹是娱乐. 我事实上想写点东西.可是近期好像做计算几何做得太多了,一种想说说不出东西的感觉,唯有写一下一些奇葩的题目了. HDU3337:Guess the number pid=3337"> http://acm.hdu.edu.cn/showproblem.php? pid=3337 题目意思: 猜数字!(32位整数范围内) 正确答案: <span style="font-size:18px;"> #include "s

写给一心刷ACM题目的学生

[来信] 老师你好,我大2013级大二的学生.大一时自学了数据结构,大二的时候参加了ACM. 现在寒假在家里刷题.可是我还想学习些东西,比如深入C 的学习,或者java.但是感觉除了刷题之外,就很迷茫,不知道以后出去工作是C 好还是java好.其实我更喜欢C ,但是如何去深入学习C 呢,我对C 的深入学习也是很迷茫的,因为对于C/C 除了用来刷题,我都不知道他们能够干什么? [回复] 你没有说你的专业,我猜想应该是计算机类的专业.下面就基于这个前提,谈谈我的想法. 很高兴你能找到一个提高编程能力

ACM 题目分类

转自: http://www.cnblogs.com/ltang/articles/1861284.html#top OJ上的一些水题(可用来练手和增加自信) (poj3299,poj2159,poj2739 ,poj1083,poj2262,poj1503,poj3006,poj2255,poj3094)初期:一.基本算法:     (1)枚举. (poj1753,poj2965)    (2)贪心(poj1328,poj2109,poj2586)    (3)递归和分治法.     (4)递

推荐acm题目

杭电  http://acm.hdu.edu.cn/onlineuser.php. 浙大  http://acm.zju.edu.cn/onlinejudge/submit.do?problemId=1http://poj.org/status惟一的阿福 password:14420121 263273 14420121 学校原来网站      http://10.1.5.253:8080/acmhome/welcome.do?method=index

ACM题目————困难的串

题目描述 如果一个字符串包含两个相邻的重复子串,则称他是“容易的串”,其他串称为"困难的串".例如,BB,ABCDACABCAB,ABCDABCD都是容易的串,而D,DC,ABDAB,CBABCBAD都是困难的串. 输入 输入正整数n和L. 输出 输出由前L个字符串组成的,字典序第k小的困难的串.例如,当L=3时,前7个困难的串分别为A,AB,ABA,ABAC,ABACA,ABACAB,ABACABA.输入保证答案不超过80个字符. 样例输入 7 3 30 3 样例输出 ABACABA