1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std;
int get(char a) { int num[26]={2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,0,7,7,8,8,8,9,9,9,0}; return num[a-'A']; }
int main() { int num[100001]; memset(num,0,sizeof(num)); char temp[1000]; int t,i,j,n,len; scanf("%d",&t;); for(i=0;i<t;i++) { scanf("%s",temp); len=strlen(temp); for(j=0;j<len;j++) { if(temp[j]>='0'&&temp;[j]<='9') num[i]=num[i]*10+temp[j]-'0'; if(temp[j]>='A'&&temp;[j]<='Z') num[i]=num[i]*10+get(temp[j]); } } sort(num,num+t); n=1; int flag=0; for(i=1;i<t;i++) { if(num[i]==num[i-1]) n++; else if(n!=1) { printf("%03d-%04d %dn",num[i-1]/10000,num[i-1]%10000,n); n=1; flag=1; } } if(num[t-1]==num[t-2]) { printf("%03d-%04d %dn",num[i-1]/10000,num[i-1]%10000,n); flag=1; } if(flag==0) printf("No duplicates.n"); }
|