快速切题 poj 1002 487-3279 按规则处理 模拟 难度:0
Time Limit: 2000MS | Memory Limit: 65536K | |
Total Submissions: 247781 | Accepted: 44015 |
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
#include <iostream>
#include <cstdio>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
map<string ,int> m;
string str;
vector <string> q;
char readchar(){
char ch;
while(1){
ch=getchar();
if(ch>='A'&&ch<'Q'){
ch=(ch-'A')/3+2+'0';
break;
}
else if(ch>'Q'&&ch<'Z'){
ch=(ch-'A'-1)/3+2+'0';
break;
}
else if(ch<='9'&&ch>='0'){
break;
}
}
return ch;
}
int main(){
int k;
cin>>k;
while(k--){
str="";
for(int i=0;i<7;i++){
str+=readchar();
}
if(m[str]){
m[str]++;
}
else {
m[str]=1;
q.push_back(str);
}
}
sort(q.begin(),q.end()-1);
bool fl=true;
for(vector<string>::iterator i=q.begin();i<q.end();i++){
if(m[*i]>1){
cout<<i->substr(0,3)<<"-"<<i->substr(3,4)<<" "<<m[*i]<<endl;
fl=false;
}
}
if(fl){
cout<<"No duplicates."<<endl;
}
return 0;
}
快速切题 poj 1002 487-3279 按规则处理 模拟 难度:0的更多相关文章
- 快速切题 poj 2993 Emag eht htiw Em Pleh 模拟 难度:0
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2806 Accepted: ...
- 快速切题 poj 3026 Borg Maze 最小生成树+bfs prim算法 难度:0
Borg Maze Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8905 Accepted: 2969 Descrip ...
- 快速切题 poj 2996 Help Me with the Game 棋盘 模拟 暴力 难度:0
Help Me with the Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3510 Accepted: ...
- 快速切题 poj 1003 hangover 数学观察 难度:0
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 103896 Accepted: 50542 Descr ...
- 快速切题 poj 2485 Highways prim算法+堆 不完全优化 难度:0
Highways Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 23033 Accepted: 10612 Descri ...
- 快速切题 sgu115. Calendar 模拟 难度:0
115. Calendar time limit per test: 0.25 sec. memory limit per test: 4096 KB First year of new millen ...
- POJ 1094 Sorting It All Out 拓扑排序 难度:0
http://poj.org/problem?id=1094 #include <cstdio> #include <cstring> #include <vector& ...
- POJ 2632 Crashing Robots 模拟 难度:0
http://poj.org/problem?id=2632 #include<cstdio> #include <cstring> #include <algorith ...
- POJ 1068 Parencodings 模拟 难度:0
http://poj.org/problem?id=1068 #include<cstdio> #include <cstring> using namespace std; ...
随机推荐
- 三张图看遍Linux性能监控、测试、优化工具
Linux 平台上的性能工具有很多,眼花缭乱,长期的摸索和经验发现最好用的还是那些久经考验的.简单的小工具.系统性能专家 Brendan D. Gregg在最近的 LinuxCon NA 2014 大 ...
- [转]Earth Mover's Distance (EMD)
转自:http://www.sigvc.org/bbs/forum.php?mod=viewthread&tid=981 Earth Mover's Distance (EMD)原文: htt ...
- iOS 机智的修改导航栏返回事件
只需要一个在自定义的基类控制器的UIBarButtonItem,在需要的时候继承该类,实现selector方法即可(如果大部分处理都是一样的,只需在基类控制器内实现操作). self.navigati ...
- ansible playbook部署ELK集群系统
一.介绍 总共4台机器,分别为 192.168.1.99 192.168.1.100 192.168.1.210 192.168.1.211 服务所在机器为: redis:192.168.1.211 ...
- 简单的linux压力测试工具webbench
wget http://blog.s135.com/soft/linux/webbench/webbench-1.5.tar.gz tar zxvf webbench-1.5.tar.gz cd we ...
- tomcat结合httpd和nginx
httpd结合tomcat: 前提:httpd版本2.4以上,编译安装 httpd:192.168.223.136 tomcat:192.168.223.146 tomcat简单创建一个额外的weba ...
- javaScript对象与JSON.stringfly(obj)
//接收json对象 var objJson = new Object(); var arr = new Array(); var obj1 = new Object(); obj1.age = 15 ...
- React Native区分安卓/iOS平台
import { Platform, } from 'react-native'; alert(JSON.stringify(Platform)): android手机弹出:{"OS&quo ...
- Could not reserve enough space for 1572864KB object heap
This problem might be caused by incorrect configuration of the daemon.For example, an unrecognized j ...
- 使用ubifs作为根文件系统的openwrt如何在进行sysupgrade时保存旧的配置
1.openwrt的默认方案(squashfs + jffs2) sysupgrade脚本直接调用default_do_upgrade更新设备树.内核.根文件系统,那么它是如何保存旧配置的呢?请看de ...