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 |
Re:谢谢你,不过还是不明白,小于10 +1, 小于100+2?有问题么?In Reply To:谢谢你,不过还是不明白,小于10 +1, 小于100+2?有问题么? Posted by:sunmoonstar_love at 2005-07-17 20:26:20 Source Problem Id:2334 User Id:00448242 Memory:40K Time:108MS Language:G++ Result:Accepted Source #include <stdio.h> #include <string.h> int n,i,lenc,lenl,res,tmp; char last[300],curr[300]; int bit(int a) { int ans = 1; while(a>=10) { ans++; a = a/10; } return ans; } int main() { scanf("%d",&n); res = 0; scanf("%s",last); if(n==1) { printf("%d\n",strlen(last)); return 0; } res += (lenl=strlen(last)); n--; while(n--) { scanf("%s",curr); lenc = strlen(curr); tmp = lenc>lenl?lenl:lenc; for(i=0; i<tmp; i++) if(last[i]!=curr[i]) break; res += lenc - i + 1; lenl = lenc; strcpy(last,curr); } printf("%d\n",res); // scanf("\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