super oj p52
来源:互联网 发布:淘宝关闭店铺 重开 编辑:程序博客网 时间:2024/05/21 01:46
1.电话号码要用string读入,否则会超时
2.按字典序排列答案时应该有2种方法
(1)把字符转化成为数字数组,直接用sort快排即可
(2)把数字借用trie数的思想(没试过)
3.‘-’的处理可以直接在读入数据时删去,或者将string转化成为char时直接不管(好得多——不易出错)
#include<iostream>#include<cstdio>#include<cmath>#include<ctime>#include<cstring>#include<string>#include<algorithm>#include<cstdlib>using namespace std;char map[26]={'2','2','2','3','3','3','4','4','4','5','5','5','6','6','6','7',0,'7','7','8','8','8','9','9','9',0};char number[30];string phone[100000];int n;int main(){freopen("lx.in","r",stdin);freopen("lx.out","w",stdout);int pos;scanf("%d",&n);for(int i=0;i<n;++i){pos=0;scanf("%s",number);for(int j=0;j<strlen(number);++j){if(number[j]=='-') continue;if(number[j]>='A'&&number[j]<='Z') number[j]=map[number[j]-'A'];phone[i]+=number[j];pos++;if(pos==3) phone[i]+='-';}}sort(phone,phone+n);int ti=1;int ok=0;for(int i=1;i<n;++i){ if(phone[i-1]!=phone[i]) {if(ti>1){cout<<phone[i-1]<<" "<<ti<<endl;ok=1;}ti=1; } else ti++;}if(ti>1){ cout<<phone[n-1]<<" "<<ti<<endl; ok=1;}if(ok==0) cout<<"No duplicates."<<endl;return 0;}
0 0
- super oj p52
- super oj p528
- [LeetCode OJ]Super Washing Machines
- p52 22
- p52 23
- p52 24
- p52 25
- p52 27
- p52 28
- p52 29
- hnu oj 13102 Super Shuttle题解
- sdut oj 2404 super prime(素数筛)
- leetcode oj java 313. Super Ugly Number
- P52第21题
- P52第22题
- P52第23题
- P52第24题
- P52第25题
- 君正T20平台生成jffs2格式rootfs
- 内存池模板 参考Poco库 简单易懂
- 用C#求A+B A一行 B一行
- CSU - 1808 地铁 (最短路,维护边)
- spring-task spring的定时任务
- super oj p52
- ubuntu下tomcat开启远程调试端口
- 安装numpy+mlk失败解决方法
- 最简便的解决Git bash 中文乱码的方法
- ThreadPool 线程池
- 也许要转业了
- elasticsearch---head插件
- 谈C#中的Delegate
- Git基础操作