Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我的很简单哟。76ms#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator