您的位置:首页 > 其它

poj 1002 487-3279

2017-03-15 21:45 351 查看
记得这是一道大一刚入学死活写不出来的题目,现在已经可以轻松写出,2333
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
const int maxn=1e5+5;
map<int,int> count_str;
int a[maxn],cnt;
char s[105];
int check(char str)
{
if(str>='A'&&str<='O')
return (str-'A')/3+2;
else if(str=='P'||str=='R'||str=='S')
return 7;
else if(str=='T'||str=='U'||str=='V')
return 8;
else if(str=='W'||str=='X'||str=='Y')
return 9;
else if(str>='0'&&str<='9')
return str-'0';
else
return -1;
}
int main()
{
int n,i,j,sum,tp;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s",s);
for(j=sum=0;s[j];j++)
{
tp=check(s[j]);
if(tp==-1)
continue;
sum*=10;
sum+=tp;
}
if(!count_str[sum])
a[cnt++]=sum;
count_str[sum]++;
}
sort(a,a+cnt);
tp=0;
for(i=0;i<cnt;i++)
if(count_str[a[i]]>1)
{
printf("%03d-%04d %d\n",a[i]/10000,a[i]%10000,count_str[a[i]]);
tp=1;
}
if(!tp)
cout<<"No duplicates."<<endl;
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: