| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
原来使用STL的结局是这样...3512K 1844MS ,我自己写的才184MSAccepted 3512K 1844MS
#include<iostream>
#include<map>
#include<string>
int hk[25]={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};
using namespace std;
int get()
{
int sum=0;
char a;
while(scanf("%c",&a)!=EOF&&a!='\n')
{
if(a=='-') continue;
else if(a>='A')
sum=sum*10+hk[a-'A'];
else sum=sum*10+a-'0';
}
return sum;
}
int main()
{
int n,i,a;
map<int,int>m;
map<int,int>::iterator it;
cin>>n;
getchar();
for(i=0;i<n;i++)
{
a=get();
it=m.find(a);
if(it!=m.end())
(*it).second++;
else m[a]=1;
}
int yes=1;
for(it=m.begin();it!=m.end();it++)
{
if((*it).second>1)
{
yes=0;
printf("%03d-%04d %d\n",((*it).first/10000),((*it).first%10000),(*it).second);
}
}
if(yes) printf("No duplicates.\n");
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator