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

我的很简单哟。76ms

Posted by bbb211985 at 2016-08-14 16:16:55 on Problem 1014
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
bool bbb;int half,a[20005];
void dfs(int qin,int value)
{
     if(qin==half)
        {bbb=true;return;}
     for(int i=value;i>=1;i--)
     {
          if(a[i]>0&&qin+i<=half)
          {
               a[i]--;
               dfs(qin+i,i);
          }
     }
}
int main()
{
     int j=1;
     while(1)
     {
          bbb=false;
          int i,sum=0,k=0;
          for(i=1;i<=6;i++)
               {
                 scanf("%d",&a[i]);
                 if(a[i]==0)k++;
                 sum=sum+i*a[i];
               }
          if(k==6)break;
          if(sum%2!=0)printf("Collection #%d:\nCan't be divided.\n\n",j++);
          if(sum%2==0)
          {
               half=sum/2;
               dfs(0,6);
               if(bbb)printf("Collection #%d:\nCan be divided.\n\n",j++);
               else printf("Collection #%d:\nCan't be divided.\n\n",j++);
          }
     }
     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