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 |
为什么我的代码WA?#include <cstdio> #include <algorithm> using namespace std; int main() { int nums[100000]; char s[16],*p; int n,t,sum,i,ct=1; bool b=false; scanf("%d",&n); for (i=0;i<n;i++) { scanf("%s",s); sum=0; for (p=s;*p;p++) { t=0; if (*p>='0'&&*p<='9') t=*p-'0'; else if (*p>='A'&&*p<'Z') { if (*p<'Q') t=(*p-'A')/3+2; else t=(*p-'A'-1)/3+2; } else continue; sum=sum*10+t; } nums[i]=sum; } std::sort(nums,nums+n); /* for (i=1;i<n;i++) { if (nums[i]==nums[i-1]) ct++; else { if (ct>1) { printf("%03d-%04d %d\n",nums[i-1]/10000,nums[i-1]%10000,ct); b=true; } ct=1; } } */ for (i=1;;) { ct=1; while (nums[i]==nums[i-1]&&i<n) { ct++; i++; } if (ct>1) { printf("%03d-%04d %d\n",nums[i-1]/10000,nums[i-1]%10000,ct); b=true; } i++; if (i>=n) break; } if (!b) printf("No duplicates.\n"); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator