快速切题 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; ...
随机推荐
- 两句话,实现android 4.4以上实现沉浸式状态栏
效果图如下,就是状态栏和actionbar保持一致的颜色,非常漂亮 1:在Activity的OnCreate函数 if (Build.VERSION.SDK_INT >= Build.VERSI ...
- Visual C++的DLL
动态链接库 (DLL) 是作为共享函数库的可执行文件. 动态链接提供了一种方法,使进程可以调用不属于其可执行代码的函数. 函数的可执行代码位于一个 DLL 中,该 DLL 包含一个或多个已被编译.链接 ...
- vux在ISO中异常 this.$vux.confirm.show
在按钮事件中调用this.$vux.confirm.show,并且启用按钮的show-loading属性 安卓正常,ios中弹窗无法显示 经过排查,iso中设置按钮的loading后,要用异步setT ...
- LocalStorage存储JSON对象的问题
LocalStorage存储JSON对象的问题 localStorage - 没有时间限制的数据存储 1 var arr=[1,2,3]; 2 localStorage.setItem(" ...
- php与js 编码解码交互
javascript: var fontcolorEncode=encodeURIComponent(fontcolor.value); //编码 php: $fontcolordecode= u ...
- ODP.NET Oracle12.1版本免安装发布(IIS WebServices)
1.ODP.NET必须的DLL OCI.DLL Oracle.DataAccess.dll OraOps12.dll msvcr100.dll oraociei12.dll oraons.dll 2. ...
- 编写和运行简单的"Hello World"操作系统内核
通常编写一个操作系统内核是一项浩大的工程.但我今天的目标是制作一个简单的内核,用比较方便的方法在虚拟机上验证它能够被grub装载和运行,并且可通过gdb进行调试,为接下去的工作创造一个基础环境. 首先 ...
- Django----Request对象&Response对象
Django 使用Request 对象和Response 对象在系统间传递状态. HttpRequest 对象: Request.body:一个字节字符串,表示原始HTTP 请求的正文.它对于处理非H ...
- Nginx基础笔记
压力测试工具:ab ab -n 请求数 -c 并发数 请求url Nginx: Nginx (engine x) 是一个高性能的HTTP和反向代理服务,也是一个IMAP/POP3/SMTP服务. 特点 ...
- 20145310 《Java程序设计》第6周学习总结
20145310 <Java程序设计>第6周学习总结 教材学习内容总结 本周主要进行第十章和第十一章的学习. 第十章 Java将输入/输出抽象化为串流,数据有来源及目的地,衔接两者的是串流 ...