题目是这样子的

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. 输出结果 -------------------------------- 看了网上人家的解决方法完全汗颜了,上代码先
 #include <cstdio>
#include <algorithm>
using namespace std;
char s[]; int Hash()
{
int sum = ;
for(int i=,k=;k<;i++)
{
if(s[i]>='' && s[i]<='')
{
sum *=;
k++;
sum+=(s[i]-'');
}
else if(s[i] >= 'A' && s[i]<'Z')
{
sum *=;
k++;
sum+=((s[i]-'A'-(s[i]>'Q'))/+);
}
}
return sum;
} int main()
{
int n;
scanf("%d",&n); int data[n];
getchar(); for(int tmp=;tmp<n;tmp++)
{
gets(s);
data[tmp] = Hash();
}
sort(data, data+n);
bool p = false;
n--;
for(int i=,num=; i<n; i+=num=)
{
while(data[i] == data[i+])
{
num++;
i++;
}
if(num>)
{
printf("%03d-%04d %d\n",data[i]/, data[i]%,num);
p = true;
}
}
if(!p)
printf("No duplicates.\n");
return ;
}

人家用一个哈希就完美解决了这个问题,果断学习一下。

如果大家有什么好的方法欢迎留言讨论奥

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

  1. ACM题目————中缀表达式转后缀

    题目描述 我们熟悉的表达式如a+b.a+b*(c+d)等都属于中缀表达式.中缀表达式就是(对于双目运算符来说)操作符在两个操作数中间:num1 operand num2.同理,后缀表达式就是操作符在两 ...

  2. HDU ACM 题目分类

    模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...

  3. ACM题目推荐(刘汝佳书上出现的一些题目)[非原创]

    原地址:http://blog.csdn.net/hncqp/article/details/1758337 推荐一些题目,希望对参与ICPC竞赛的同学有所帮助. POJ上一些题目在http://16 ...

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

    本文全然没有技术含量,纯粹是娱乐. 我事实上想写点东西.可是近期好像做计算几何做得太多了,一种想说说不出东西的感觉,唯有写一下一些奇葩的题目了. HDU3337:Guess the number pi ...

  5. ACM题目————STL练习之求次数

    题目地址:http://acm.nyist.net/JudgeOnline/problem.php?pid=1112 描述 题意很简单,给一个数n 以及一个字符串str,区间[i,i+n-1] 为一个 ...

  6. ACM题目————zoj问题

    题目1006:ZOJ问题 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:20322 解决:3560 题目描述: 对给定的字符串(只包含'z','o','j'三种字符),判断他是否能AC. ...

  7. ACM题目————又见拦截导弹

    描述 大家对拦截导弹那个题目应该比较熟悉了,我再叙述一下题意:某国为了防御敌国的导弹袭击,新研制出来一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:它的第一发炮弹能够到达任意的高度,但是以后每一发炮 ...

  8. ACM题目————还是畅通工程

    Submit Status Description 某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离.省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路 ...

  9. ACM题目————小A的计算器

    Description 以往的操作系统内部的数据表示都是二进制方式,小A新写了一个操作系统,系统内部的数据表示为26进制,其中0-25分别由a-z表示.  现在小A要在这个操作系统上实现一个计算器,这 ...

  10. ACM题目————二叉树的遍历

    一.二叉树的后序遍历: 题目描述 给定一颗二叉树,要求输出二叉树的深度以及后序遍历二叉树得到的序列.本题假设二叉树的结点数不超过1000 输入 输 入数据分为多组,第一行是测试数据的组数n,下面的n行 ...

随机推荐

  1. 泛型、注解、log4j

    泛型.注解.log4j 泛型:将运行阶段的类型错误提前到编译阶段. 声明泛型必须两端的一致,要么左面有,要么右边有,两边都有的两边必须一致. 泛型方法: static 之后 返回类型之前进行声明 泛型 ...

  2. Python 随即生成DAG(有向无环图)

    给校队选拔赛出了道DAG上的背包问题,需要生成DAG数据. 最开始使用的方法是先随机生成再判环,如果有环就重新生成.这种方法得到DAG的概率随着点数和边数的增加而急速降低,为了一个DAG要生成很多次, ...

  3. Web-----》》》 一般处理程序 ashx

    一般处理程序 后缀: 前台页面:.ashx 后台页面:.ashx.cs 打开方式:右键程序集--在浏览器中查看--输入url(如http://localhost:6560/firstAshx.ashx ...

  4. java打包/命令行方式运行jar(命令行进行程序测试)

    public class Testtmp { public static void main(String[] args) { // TODO Auto-generated method stub f ...

  5. Windows vista以上模拟Alt Ctrl Delete

    之前客户要求我们能够在windows登陆界面能够用指定账户批量控制机器登陆,然后用windows credentials provider(vista以上,xp需要用Gina)实现了这个功能,这期间遇 ...

  6. IE 第三方设置cookie失效

    公司的产品,采用多服务分摊压力,中间必须涉及的当然是单点登陆.一般的单点登陆都是通过去用户中心登陆,302或页面回调的方式,返回到登陆前的页面. 公司项目,想用户体验更好些,采用弹框登陆,可以考虑if ...

  7. SVG image xlink:href 设置失败

    公司比较频繁的业务需求,需要在地图上面,标注地区的信息,考虑到兼容性问题,在实际开发中是通过raphael.js绘制地图信息,进行相关交互 产品部门同事辛苦的画SVG地图,可配置地图块与实际地区cod ...

  8. PHP EOF(heredoc)的使用

    <?php /* Heredoc技术,在PHP手册和技术书籍中一般没有详细讲述,只是提到了这是一种Perl风格的字符串输出技术. 目前一些论坛程序和CMS系统使用了这种技术,前不久看一个朋友的P ...

  9. 使用Notepad++开发python配置笔记

    这是我在python学习过程中,收集整理的一些notepadd++环境配置方法. 1.配置制表符 Notepad++ ->"设置"菜单->"首选项" ...

  10. response妙用

    1.弹框提示信息 response.getWriter().print("<script>alert('文件不存在或已删除!');</script>"); ...