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

怪了,按未名上的证明,最后的数组开到200就绝对够的,为什么我开到500还RE?开到5000才过呢?

Posted by houxuanfelix at 2006-08-04 08:23:22 on Problem 1014
#include <stdio.h>
int    f[10],t[5000],flag,sum,co[5000];

int dowith()
{
     int i;
     if (f[1]>=6)  return 1;
     else
     {
         if (f[6]>7)
           if (f[6]%2==0)   f[6]=6;
           else   f[6]=7;
         if (f[5]>12)
            if (f[5]%2==0)  f[5]=12;
            else            f[5]=11;
         if (f[4]>8)
            if (f[4]%2==0)  f[4]=8;
            else            f[4]=7;
         if (f[3]>8)
            if (f[3]%2==0)  f[3]=8;
            else            f[3]=7;
         if (f[2]>4)
            if (f[4]%2==0)  f[4]=4;
            else            f[4]=3;
         return 0;
     }
}

int solve(int w)
{
    int i,j;
    for (i=0;i<500;i++)
    {
           t[i]=0;
    }
    t[0]=1;
    for (i=1;i<=6;i++)
    if (f[i])
    {
        for (j=1;j<i;j++)
          if (t[j])   co[j]=0;
        for (j=i;j<500;j++)
        {
            if (t[j])   co[j]=0;
            else
                if (t[j-i] && co[j-i]<f[i])
                {
                     t[j]=1;
                     co[j]=co[j-i]+1;
                }
        }
    }
    if (t[w])    return 1;
    else         return 0;
}  

int main()
{
    int    i,caset=0;
    while (scanf ("%d%d%d%d%d%d",&f[1],&f[2],&f[3],&f[4],&f[5],&f[6])!=EOF&&(f[1]||f[2]||f[3]||f[4]||f[5]||f[6]))
    {
          caset++;
          printf ("Collection #%d:\n",caset);
          sum=0;
          for (i=1;i<7;i++)  sum+=i*f[i];
          if (sum%2==1)
          {
               printf("Can't be divided.\n\n");
               continue;
          }
          flag=dowith();
          if (flag)   printf ("Can be divided.\n\n");
          else
          {
               sum=0;
               for (i=1;i<7;i++)
                    sum+=i*f[i];
               sum/=2;
               i=solve(sum);
               if (i)   printf("Can be divided.\n\n");
               else     printf("Can't be divided.\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