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

Re:有哪位大神可以帮我看一下1014题我错在哪里吗???orz

Posted by Acceleratednpc at 2022-03-25 20:18:41 on Problem 1014
In Reply To:有哪位大神可以帮我看一下1014题我错在哪里吗???orz Posted by:JiangNing97 at 2018-05-24 17:23:10
> #include<stdio.h>
> 
> int s[20000]={0};
> 
> 
> int dfs(int now,int x)
> {
>     int i;
>     if(now==0) return 1;
>     if(now&&!x) return 0;
>     for(i=x-1;i>=0;i--)
>     {
>         if(now>=s[i])
>         {
> 
>             if(dfs(now-s[i],i)) return 1;
>             else
>             {
> 
>                 while(i&&s[i]==s[i-1]) i--;
>                 if(i==0) return 0;
>             }
>         }
> 
> 
>     }
>     //return 0;
> }
> 
> int main()
> {
>     int a[6];
>     int k=0,i,sum,j,n;
>     while(scanf("%d %d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5]),a[0]+a[1]+a[2]+a[3]+a[4]+a[5])
>     {
> 
> 
>             k++;
>             sum=0;j=0;n=0;
>             for(i=0;i<6;i++)
>             {
>                 sum+=(i+1)*a[i];
>                 n+=a[i];
>             }
>             if(sum%2==1)
>             {
>                 printf("Collection #%d:\nCan't be divided.\n\n",k);
>             }
>             else
>             {
>                 for(i=0;i<6;i++)
>                 {
>                     while(a[i])
>                     {
>                         s[j++]=i+1;
>                         a[i]--;
>                     }
>                 }
> 
>                 if(dfs(sum/2,n)) printf("Collection #%d:\nCan be divided.\n\n",k);
>                 else printf("Collection #%d:\nCan't be divided.\n\n",k);
>             }
>         }
> 
>     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