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 |
10000000# include <stdio.h> # include <ctype.h> # include <string.h> # define N 10000000 int n, f[N]; int m(char ch) { if (ch < 'Q') return (ch-'A')/3 + 2; switch(ch) { case 'R':case 'S':return 7; case 'T':case 'U':case 'V':return 8; case 'W':case 'X':case 'Y':return 9; } } int g(char *s) { int i, ret = 0; for (i = 0; s[i]; ++i) { if (isdigit(s[i])) ret = ret*10 + s[i]-'0'; else if (isalpha(s[i])) ret = ret*10 + m(s[i]); } return ret; } int main() { int i, dup; char buf[105]; while (~scanf("%d", &n)) { memset(f, 0, sizeof(f)); for (i = 0; i < n; ++i) { scanf("%s", buf); ++f[g(buf)]; } dup = 1; for (i = 0; i < 10000000; ++i) if (f[i] > 1) printf("%03d-%04d %d\n", i/10000, i%10000, f[i]), dup = 0; if (dup) 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