题目:http://poj.org/problem?id=1002

  我知道你们最需要的是这个 [ 手动滑稽 ]

  

  STD 给出的方法是丢进一个数组,然后排序,相邻的是重复的

  这个方法,时间复杂度很不错,也确实很好,但是最快的写法是

  直接丢进对应的数组统计,然后 for 一遍数组看是否大于 1

  注意没有满 7 位的时候要输出前导零

 #include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std; char a[],s[],w[];
int b[];
int main()
{
int i,j,n,len,x;
bool flag=;
scanf("%d\n",&n);
a['A']=a['B']=a['C']='';
a['D']=a['E']=a['F']='';
a['G']=a['H']=a['I']='';
a['J']=a['K']=a['L']='';
a['M']=a['N']=a['O']='';
a['P']=a['R']=a['S']='';
a['T']=a['U']=a['V']='';
a['W']=a['X']=a['Y']='';
for (i=;i<=n;i++)
{
scanf("%s",s);
len=strlen(s);
x=;
for (j=;j<len;j++)
{
if (s[j]>='A'&&s[j]<='Z') s[j]=a[s[j]];
if (s[j]>=''&&s[j]<='') x=x*+s[j]-'';
}
b[x]++;
}
for (i=;i<;i++)
if (b[i]>)
{
for (x=i,j=;j<=;j++)
{
w[j]=x%+'';
x/=;
}
for (;j;j--) putchar(j>?w[j-]:j<?w[j]:'-');
printf(" %d\n",b[i]);
flag=;
}
if (flag) printf("No duplicates.\n");
return ;
}

  见到的好博客,可以看出真的是用心写了

  http://blog.csdn.net/thebestdavid/article/details/10986813

版权所有,转载请联系作者,违者必究

联系方式:http://www.cnblogs.com/hadilo/p/5932395.html

随机推荐

  1. Rest风格WEB服务(Rest Style Web Service)的真相

    http://blog.csdn.net/jia20003/article/details/8365585 Rest风格WEB服务(Rest Style Web Service)的真相 分类: J2E ...

  2. sqlserver 2005列转行

    isnull(stuff((select ',' + d.comname from projemp a left outer join emps c on a.empid = c.empidleft ...

  3. 剑指offer系列62---两个链表的公共结点

    [题目]输入两个链表,找出它们的第一个公共结点. * [思路]1 获取两链表的长度: * 2 让长的链表先走n步后此时走到短链表起始位置: * 3 两链表同时遍历,直至相同,这时返回第一个公共结点. ...

  4. json换行符的处理

    JS端的: var s = JSON.stringify(str); var ss = s.replace(/\\n/g, "\\n") .replace(/\\'/g, &quo ...

  5. erlang和java通信

    连接在 https://guts.me/2014/07/27/erlang-communicates-with-java/ 代码在 https://github.com/mingshun/jinter ...

  6. C#将字符串转换为整型的三种方法的总结

    在C#中,要将一个字符串或浮点数转换为整数,基本上有三种方法: (1)使用强制类型转换:(int)浮点数 (2)使用Convert.ToInt32(string) (3)使用int.Parse(str ...

  7. MySQL key/value存储方案(转)

    需求 250M entities, entities表共有2.5亿条记录,当然是分库的. 典型解决方案:RDBMS 问题:由于业务需要不定期更改表结构,但是在2.5亿记录的表上增删字段.修改索引需要锁 ...

  8. Java执行main方法,异常为:could not find the main class.program will exit

    未解决. Java执行方法,异常为:could not find the main class.program will exitmain 原文地址:http://rogerfederer.iteye ...

  9. ADF_Tutorials系列17_ADF Faces_ADF预定义组件的创建和使用

    2013-05-01 Created By BaoXinjian

  10. 转--Android学习笔记-实用代码合集

    http://blog.csdn.net/yf210yf/article/details/7295577 转载请注明原文出处:奔跑的蜗牛(袁方的技术博客)点击打开链接 一.当利用textview显示内 ...