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

这一题有什么特殊数据吗? 为什么我总是WA!!!!

Posted by ybbaigo at 2008-03-21 23:28:51 on Problem 1362
一楼的测试数据我都过了
这是我的代码:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define NUM 10000

int main()
{
    int i, j, m, n, s, t, w;
    int rank[NUM];
    int digit[NUM];
    int skew[NUM];
    for (i=0; rank[i-1]<=100663270; i++)
    {
        rank[i] = (int)pow(2, (double)(i+1))-1;
    }
    s = i-2;
    while (scanf ("%d", &n)!=EOF && n>0)
    {
        for (i=0; i<n; i++)
        {
            scanf ("%d", &m);
            if (m==0)
            {
                printf ("%d []\n", m);
                continue;
            }
            w = m;
            for (j=0; j<s; j++)
            {
                digit[j] = 0;
            }
            for (j=s; j>=0; j--)
            {
                if ((m/rank[j])>0)
                {
                    digit[j] = m/rank[j];
                    m = m-digit[j]*rank[j];
                }
            }
            t = 0;
            for (j=0; j<s; j++)
            {
                if (digit[j]==2)
                {
                    skew[t] = j;
                    t++;
                    skew[t] = j;
                    t++;
                }
                else if (digit[j]==1)
                {
                    skew[t] = j;
                    t++;
                }
            }
            printf ("%d [%d", w, skew[0]);
            for (j=1; j<t; j++)
            {
                printf (",%d", skew[j]);
            }
            printf ("]\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