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 |
蒟蒻的AC纪念最初忽略了开头为0的情况。 挺慢,该怎么优化······ 膜拜那些快速通过的大神! #include <cstdio> #include <map> #include <ctype.h> using namespace std; #define elif else if int Deal(int c) { if (isdigit(c)) return c; elif (c>='A' && c <= 'C') return '2'; elif (c>='D' && c <= 'F') return '3'; elif (c>='G' && c <= 'I') return '4'; elif (c>='J' && c <= 'L') return '5'; elif (c>='M' && c <= 'O') return '6'; elif (c>='P' && c <= 'S') return '7'; elif (c>='T' && c <= 'V') return '8'; elif (c>='W' && c <= 'Y') return '9'; else return -1; } int Myscan() { int val = 0; int c; while ((c = getchar()) != EOF && c != ' ' && c != '\n') { if (c=='-') continue; else val = val*10 + Deal(c)-'0'; } while (c ==' ') c = getchar(); return val; } int main() { int i; int n; bool mark = false; const int k= 10000; map<int, int>pbook; map<int, int>::iterator it; n = Myscan(); for(i=1;i<=n;i++) pbook[Myscan()]++; for (it = pbook.begin(); it != pbook.end(); it++) { if(it->second > 1) { if(!mark) mark = true; printf("%03d-%04d %d\n",it->first/k,it->first%k,it->second); } } if(!mark) 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