poj 1002 487-3279(水)
来源:互联网 发布:关联查询sql 编辑:程序博客网 时间:2024/05/18 01:35
poj 1002 487-3279
题意:给你n个字符串,均可以化简成为标准的字符串,问化简后的标准字符串的具体串,和每种的标准串的个数。
题解:将n个字符串化为全数字的字符串,进行字典序排序后,输出答案时加上需要的‘-’即可。
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int N = 100010;int p[26] = {2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9};struct point{ char a[8];} ans[N];bool cmp(point x, point y){ return strcmp(x.a,y.a) < 0;}int main(){ int n; scanf("%d",&n); for(int i = 0; i < n; i++) { char s[100]; scanf("%s",s); int len = strlen(s); int k = 0; for(int j = 0; j < len; j++) { if(s[j] >= 'A' && s[j] <= 'Y') ans[i].a[k++] = p[s[j]-'A']+'0'; else if(s[j] == '-') continue; else ans[i].a[k++] = s[j]; } ans[i].a[k] = '\0'; } sort(ans,ans+n,cmp); bool pan = 1; int i = 0,j; while(i < n) { j = i; i++; while(i < n && strcmp(ans[i].a,ans[j].a) == 0) i++; if(i - j > 1) { for(int k = 0; k <= 6; k++) { if(k == 3) printf("-"); printf("%c",ans[j].a[k]); } printf(" %d\n",i-j); pan = 0; } } if(pan) puts("No duplicates."); return 0;}
0 0
- poj 1002 487-3279(水)
- poj 1002 487-3279(水)
- POJ 1002 487-3279 水
- POJ--1002 487-3279
- POJ 1002 487-3279
- POJ 1002 487-3279
- POJ 1002 487-3279
- poj 1002 "487-3279"
- POJ 1002 487-3279
- poj 1002 487-3279
- poj 1002 487-3279
- POJ-1002 487-3279
- poj 1002 487-3279
- POJ 1002 487-3279
- poj 1002 487-3279
- (POJ 1002) 487-3279
- POJ 1002 487-3279
- POJ 1002 487-3279
- [LeetCode]Candy
- 自定义URL Protocol Handler 呼出应用程序
- 在 github 建立blg
- linux回删密码,密码以*显示
- tcpdump dump 网络流量
- poj 1002 487-3279(水)
- 带分割线的TextView和LinearLayout
- LateX在windows中运用MiKTeX
- String的不可变性
- DBCP连接池配置参数说明
- 第14周练习项目二 学生成绩处理函数版
- layer,jquery,laydate前端组件
- 观光旅游
- 傻子能看懂的并查集入门讲解