| ||||||||||
| 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 | |||||||||
那位高手能帮忙看看 我的1002。不知道为什么从超时变成了wr!!!!#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
int s[100001];
string ch(string str)
{
int t=str.size(),i;
string str1;
for(i=0;i<t;++i)
{
if(str[i]>='A'&&str[i]<='Z')str1+=str[i];
else
if(str[i]>='0'&&str[i]<='9')
str1+=str[i];
}
return str1;
}
int at(string str)
{
int t=str.size(),i,sum=0;
for(i=0;i<t;++i)
{
switch(str[i])
{
case 'A':
case 'B':
case 'C':sum+=2;break;
case 'D':
case 'E':
case 'F':sum+=3;break;
case 'G':
case 'H':
case 'I':sum+=4;break;
case 'J':
case 'K':
case 'L':sum+=5;break;
case 'M':
case 'N':
case 'O':sum+=6;break;
case 'P':
case 'R':
case 'S':sum+=7;break;
case 'T':
case 'U':
case 'V':sum+=8;break;
case 'W':
case 'X':
case 'Y':sum+=9;break;
default: sum+=str[i]-'0';
}
sum*=10;
}
return sum/10;
}
void my_put(int i,short int j)
{
int he,po;
he=i%10000,po=i/10000;
if(po>=100)printf("%d-",po);
else if(po>=10)printf("0%d-",po);
else printf("00%d-",po);
if(he>=1000)printf("%d",he);
else if(he>=100)printf("0%d",he);
else if(he>=10)printf("00%d",he);
else printf("000%d",he);
printf(" %d\n",j);
}
int main()
{
int N,i,j;
string str;
bool flag;
cin>>N;
flag=true;
for(i=0;i<N;++i){
cin>>str;
s[i]=at(ch(str));
}
sort(s,s+N);
for(i=0;i<N;++i)my_put(s[i],0);
int temp=s[0];
j=1;
for(i=1;i<N;++i)
{
if(temp==s[i])j++;
else
{
if(j>1)
{
my_put(temp,j);
flag=false;
}
j=1;
temp=s[i];
}
}
if(j>1){my_put(temp,j);flag=false;}
if(flag)cout<<"No duplicates."<<endl;
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator