POJ 1002 487-3279 map
Time Limit: 2000MS | Memory Limit: 65536K | |
Total Submissions: 287874 | Accepted: 51669 |
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
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
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <map>
#include <string>
using namespace std;
int num[]=//初始化每个字母对应的值
{
,,,
,,,
,,,
,,,
,,,
,,,,
,,,
,,,
};
map<int,int>s;
char buf[];
int main()
{
int t;
cin >> t;
bool flag = false;
for(int i=;i<t;i++)
{
cin >> buf;
int c = ;
for(int j=;buf[j];j++)//用数直接存下号码
{
if(isdigit(buf[j]))
c = c*+buf[j]-'';
else if(isalpha(buf[j]))
c = c*+num[buf[j]-'A'];
}
s[c]++;
}
for(map<int,int>::iterator it = s.begin();it!=s.end();it++)
if(it->second > )
{
flag = true;
printf("%03d-%04d %d\n",it->first/,it->first%,it->second);//注意输出时可以通过取余,除以10000来输出后四位,前四位,加个0避免省略0的情况,这种方法个人觉得挺好的
}
if(!flag)
puts("No duplicates.");
return ;
}
POJ 1002 487-3279 map的更多相关文章
- POJ 1002 487-3279 (map )
title: 487-3279 map POJ1002 tags: [map] 题目链接 Description Businesses like to have memorable telephone ...
- 字符串专题: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 ...
- [POJ 1002] 487-3279 C++解题报告
487-3279 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 228365 Accepted: 39826 D ...
- POJ 1002 487-3279(字典树/map映射)
487-3279 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 309257 Accepted: 5 ...
- POJ 1002 487-3279(map映照容器的使用)
Description Businesses like to have memorable telephone numbers. One way to make a telephone number ...
- 开篇,UVA 755 && POJ 1002 487--3279 (Trie + DFS / sort)
博客第一篇写在11月1号,果然die die die die die alone~ 一道不太难的题,白书里被放到排序这一节,半年前用快排A过一次,但是现在做的时候发现可以用字典树加深搜,于是乐呵呵的开 ...
- poj 2418 Hardwood Species (map)
题目:http://poj.org/problem?id=2418 在poj 上交题总是有各种错误,再次感叹各个编译器. c++ AC代码,G++为超时,上代码: #include<cstdio ...
- poj 2503 Babelfish (查找 map)
题目:http://poj.org/problem?id=2503 不知道为什么 poj 的 数据好像不是100000,跟周赛的不一样 2000MS的代码: #include <iostrea ...
随机推荐
- 【iOS】安装 CocoaPods
1. 打开 terminal 2. 移除现有 Ruby 默认源 $ gem sources --remove https://rubygems.org/ 3. 使用新的源 $ gem sources ...
- DES、3DES、AES、PBE对称加密算法实现及应用
1.对称加密算法概述 对称加密算法是应用较早的加密算法,技术成熟.在对称加密算法中,数据发信方将明文和加密密钥一起经过特殊加密算法处理后,使其变成复杂的加密密文发送出去.收信方收到密文后,若想解读原文 ...
- Oracle DBLink跨数据库访问SQL server数据同步 踩坑实录
项目需求:这里暂且叫A公司吧,A公司有一套人事管理软件,需要与我们公司的软件做人员信息同步,A公司用的是SQL server数据库,我们公司用的Oracle,接口都不会开发(一万句"fuck ...
- JVM内存结构 VS Java内存模型 VS Java对象模型
前面几篇文章中, 系统的学习了下JVM内存结构.Java内存模型.Java对象模型, 但是发现自己还是对这三者的概念和区别比较模糊, 傻傻分不清楚.所以就有了这篇文章, 本文主要是对这三个技术点再做一 ...
- 1、大型项目的接口自动化实践记录--robotframework环境搭建
因为人力.团队技术问题,选用robotframework来做自动化,首先说下环境搭建 齐涛道长的入门教程非常棒:http://blog.csdn.net/tulituqi/article/detail ...
- Jmeter 01 Jmeter下载安装及入门
jmeter简介 Apache JMeter是Apache组织开发的基于Java的压力测试工具.用于对软件做压力测试,它最初被设计用于Web应用测试,但后来扩展到其他测试领域.--百度百科 下载 下载 ...
- Codeforces 343D Water Tree
题意简述 维护一棵树,支持以下操作: 0 v:将以v为跟的子树赋值为1 1 v:将v到根节点的路径赋值为0 2 v:询问v的值 题解思路 树剖+珂朵莉树 代码 #include <set> ...
- go 学习笔记之值得特别关注的基础语法有哪些
在上篇文章中,我们动手亲自编写了第一个 Go 语言版本的 Hello World,并且认识了 Go 语言中有意思的变量和不安分的常量. 相信通过上篇文章的斐波那契数列,你已经初步掌握了 Go 语言的变 ...
- 在使用Lists.transform时,不会直接生成PurchaseOrderVo的集合对象,而是生成一个Function的集合
但是在使用Lists.transform时,不会直接生成PurchaseOrderVo的集合对象,而是生成一个Function的集合,在循环的时候,会去调用apply 生成一个PurchaseOrde ...
- 解放双手——相机与IMU外参的在线标定
本文作者 沈玥伶,公众号:计算机视觉life,编辑部成员 一.相机与IMU的融合 在SLAM的众多传感器解决方案中,相机与IMU的融合被认为具有很大的潜力实现低成本且高精度的定位与建图.这是因为这两个 ...