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:拙代码,供大家参考

Posted by ivan2013 at 2013-04-06 23:07:35 on Problem 1014
In Reply To:拙代码,供大家参考 Posted by:TSERROF at 2012-09-17 16:15:07
> 
> #include <cstdio>
> using namespace std;
> int marble[6];
> bool DFS(int sum)
> {
> 	if(sum==0)return true;
> 	for(int i=6;i>0;--i)
> 	{
> 		if(sum>=i && marble[i-1]>0)
> 		{
> 			--marble[i-1];
> 			int t=sum-i;
> 			if(DFS(t))return true;
> 		}
> 	}
> 	return false;
> }
> int main()
> {
> 	int s=1;
> 	while(scanf("%d%d%d%d%d%d",&marble[0],&marble[1],&marble[2],&marble[3],&marble[4],&marble[5])!=EOF && (marble[0]!=0 || marble[1]!=0 ||marble[2]!=0 || marble[3]!=0 || marble[4]!=0 ||marble[5]!=0))
> 	{
> 		int sum=marble[0]+marble[1]*2+marble[2]*3+marble[3]*4+marble[4]*5+marble[5]*6;
> 		if(sum%2)
> 		{
> 			printf("Collection #%d:\nCan't be divided.\n\n",s++);
> 			continue;
> 		}
> 		else
> 		{
> 			if(DFS(sum/2))printf("Collection #%d:\nCan be divided.\n\n",s++);
> 			else printf("Collection #%d:\nCan't be divided.\n\n",s++);
> 		}
> 	}
> 	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