poj 1002:487-3279(水题,提高题 / hash)
| Time Limit: 2000MS | Memory Limit: 65536K | |
| Total Submissions: 236746 | Accepted: 41288 |
Description
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
Output
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
Source
#include <iostream>
#include <stdio.h>
using namespace std;
#define MAXN 10000000
int a[MAXN+]={};
int Map(char c) //映射关系
{
if(''<=c && c<='')
return c-'';
else if(c=='A' || c=='B' || c=='C')
return ;
else if(c=='D' || c=='E' || c=='F')
return ;
else if(c=='G' || c=='H' || c=='I')
return ;
else if(c=='J' || c=='K' || c=='L')
return ;
else if(c=='M' || c=='N' || c=='O')
return ;
else if(c=='P' || c=='R' || c=='S')
return ;
else if(c=='T' || c=='U' || c=='V')
return ;
else if(c=='W' || c=='X' || c=='Y')
return ;
else
return -;
}
int main()
{
char s[],c;
int i,j,n;
scanf("%d%c",&n,&c);
for(i=;i<=n;i++){ //输入n个数
scanf("%s",s);
int tel = ;
for(j=;s[j];j++){
int t = Map(s[j]);
if(t==-) continue;
tel = tel*+t;
}
a[tel]++; //次数加1
}
int f=false; //有无重复
for(i=;i<MAXN;i++) //输出
if(a[i]>){
f=true;
printf("%03d-%04d %d\n",i/,i%,a[i]);
}
if(!f) cout<<"No duplicates."<<endl;
return ;
}
Freecode : www.cnblogs.com/yym2013
poj 1002:487-3279(水题,提高题 / hash)的更多相关文章
- poj 2236:Wireless Network(并查集,提高题)
Wireless Network Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 16065 Accepted: 677 ...
- poj 3321:Apple Tree(树状数组,提高题)
Apple Tree Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 18623 Accepted: 5629 Descr ...
- POJ 1488 Tex Quotes --- 水题
POJ 1488 题目大意:给定一篇文章,将它的左引号转成 ``(1的左边),右引号转成 ''(两个 ' ) 解题思路:水题,设置一个bool变量标记是左引号还是右引号即可 /* POJ 1488 T ...
- C基础的练习集及测试答案(提高题)
提高题:1.编写程序,随机生成一个1~10内的数,让对方猜3次.如果3次内能猜中则输出“恭喜你”:若3次内猜不中则输出正确答案.C语言中提供生成随机数的函数rand()用法:①所需头文件:#inclu ...
- [POJ 1002] 487-3279 C++解题报告
487-3279 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 228365 Accepted: 39826 D ...
- POJ 3627 Bookshelf 贪心 水~
最近学业上堕落成渣了.得开始好好学习了. 还有呀,相家了,好久没回去啦~ 还有和那谁谁谁... 嗯,不能发表悲观言论.说好的. 如果这么点坎坷都过不去的话,那么这情感也太脆弱. ----------- ...
- 字符串专题:map POJ 1002
第一次用到是在‘校内赛总结’扫地那道题里面,大同小异 map<string,int>str 可以专用做做字符串的匹配之类的处理 string donser; str [donser]++ ...
- POJ 1002 487-3279
A - 487-3279 Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit ...
- Educational Codeforces Round 12补题 经典题 再次爆零
发生了好多事情 再加上昨晚教育场的爆零 ..真的烦 题目链接 A题经典题 这个题我一开始推公式wa 其实一看到数据范围 就算遍历也OK 存在的问题进制错误 .. 思路不清晰 两个线段有交叉 并不是端点 ...
随机推荐
- Flask 模板语言
Flask使用的是Jinja2模板引擎 举个例子: from flask import Flask, render_template app = Flask(__name__) @app.route( ...
- mysql中You can't specify target table for update in FROM clause错误
原SQL delete from DEP_SYSTEM_PORTLET_SETTINGS where ID in ( select ID from DEP_SYSTEM_PORTLET_SETTING ...
- MySQL表结构及数据的备份
1.Navicat for MySQL 选择要保存的表,右键转储SQL文件,导出的sql文件中包括表的定义和表的数据两部分. 其他办法: (1) create table dust select * ...
- 怎样搭建PHP开发环境
搭建PHP开发环境首先第一步要 下载开发环境 wampserver 下载sublime text 2 sublime使用技巧 1:安装漂亮的编程字体http://pan.baidu.com/s/1xM ...
- sublime 支持php语法错误提示的插件
求一个好用的sublime 支持php语法错误提示的插件.我装过sublimelinter,但是有时候出现错误也不会提示. 可以试试http://cs.sensiolabs.org/ 这个看哦它有对应 ...
- meteor 为基础,联合 Apollo + React + React-Router
Graphql with Apollo, Meteor and React: https://janikvonrotz.ch/2016/10/09/graphql-with-apollo-meteor ...
- centos 7 python2.7.5升级到3.5.2
centos 7 python2.7.5升级到3.5.2 下载python3.5.2 wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2 ...
- centos6.5 nginx开机启动
/etc/init.d/下添加nginxd文件,内容如下: #!/bin/bash # #chkconfig: - #description: Nginx is a World Wide Web se ...
- 百度和google的区别
一.百度 二.google
- WPF ListView 排序
代码如下: list为ListView组件.Score为要排序的列,也是绑定的属性. CollectionViewSource.GetDefaultView(list.ItemsSource).Sor ...