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

Re:这题什么意思?按你这样理解是每次都只和上一个输入的作比较,那么then the second string is stored as [j]ai+1,j+1ai+1,j+2... ai+1,q,是什么意思?

Posted by fxlbest at 2005-10-29 21:01:10 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