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

my solution

Posted by yucaierxiao at 2009-02-19 01:06:00 on Problem 3438
似乎不太难呢
好像有个叫做O(n)扫描的东西

#include <stdio.h>
long n;
void work()
{
     char s[2000];
     long l,i;
     long ans;
     scanf("%s",s);
     l=strlen(s);
     s[l]=10;
     ans=0;
     for(i=0;i<l;i++)
     {
       ans++;
       if(s[i]!=s[i+1])
       {
        printf("%ld%ld",ans,s[i]-'0');
        ans=0;
       }
     }
     printf("\n");
}
int main()
{
    long i;
    scanf("%ld",&n);
    for(i=1;i<=n;i++)
     work();
    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