Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

where [j] is a single character with code j.

Posted by 00448242 at 2005-07-17 20:18:42 on Problem 2334
In Reply To:帮我看看这个简单题,怎么会WA? Posted by:sunmoonstar_love at 2005-07-17 20:11:48
> #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 + bit(i);    
>         lenl = lenc;
>         strcpy(last,curr);    
>     }
>     printf("%d\n",res);    
>    // scanf("\n");    
>     return 0;
> }    

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator