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

十分郁闷,在ZOJ上通过了,在这竟过不了

Posted by buctears at 2011-04-10 09:30:21 on Problem 1565
In Reply To:什么叫朴素的模拟 Posted by:lulyon at 2011-03-14 01:29:23
请高手指教……
#include "stdio.h"
#include "string.h"
int main ()
{
    long i,j,n,len;
    int base[31];
    base[0] = 1;
    for (i = 1;i < 31;i ++)
        base[i] = 2*base[i - 1] +1;
    char skew[32];
    while (scanf ("%s",skew))
    {
        n = 0;
        if (strcmp(skew,"0") == 0) break;
        len  = strlen (skew);

        j = 0;
        for (i = len -1;i >= 0;i --)
        n += (skew[i] - '0') * base[j++];
        printf ("%ld\n",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