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 zwzmzd_nju at 2009-09-18 23:30:05 on Problem 1014
#include <iostream>
using namespace std;
int main()
{
    int f[200000];
    int i,j,k,v,z;
    int x[7];
    //freopen("1014.in","r",stdin);
    //freopen("1014.out","w",stdout);
    z=0;
    while (cin>>x[1]>>x[2]>>x[3]>>x[4]>>x[5]>>x[6])
    {
        k=0;
        for (i=1;i<=6;i++)
          k+=i*x[i];
        x[0]=0;
        if (k==0) break;
        v=k/2;
        for (i=1;i<=v;i++)
          f[i]=-1;
        f[0]=0;
        for (i=1;i<=6;i++)
          for (j=0;j<=v;j++)
            if ((f[j]>=0) and (f[j]<=x[i-1])) f[j]=0;
              else if ((j>=i) and (f[j-i]>=0) and (f[j-i]<=x[i])) f[j]=f[j-i]+1;
              else f[j]=-1;
        z++;
        cout<<"Collection #"<<z<<":"<<endl;
        if ((f[v]>=0) and (f[v]<=x[6])) cout<<"Can be divided."<<endl;
          else cout<<"Can't be divided."<<endl;
        cout<<endl;
    } 
    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