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 zhucheng at 2004-12-09 09:35:13 on Problem 1014
In Reply To:Re:关于此题可以证明如下结论。。。。。 Posted by:zhucheng at 2004-12-08 23:11:11
> my code
> 
> #include <iostream>
> using namespace std;
> int marble[6];
> const int limit[]={3,4,5,4,6,5};
> 
> 
> bool half(int d,int next)
> {
> 	if(d==0)
> 		return true;
> 	if(next==0)
> 		return false;
> 	int i;
> 	for(i=marble[next-1];i>=0;i--)
> 	{
> 		if(d>=i*next)
> 		{
> 			marble[next-1]-=i;
> 			if(half(d-i*next,next-1))
> 				return true;
> 			marble[next-1]+=i;
> 		}
> 	}
> 	return false;
> }
> 
> int main()
> {
> 	int i,test=1,sum=0;
> 	for(i=0;i<6;i++)
> 	{
> 		cin>>marble[i];
> 		if(marble[i]>limit[i])
> 		{
> 			marble[i]=limit[i]-(marble[i]-limit[i])%2;
> 		}
> 		sum+=marble[i]*(i+1);
> 	}
> 	while(sum!=0)
> 	{
> 		if(sum%2==0&&half(sum/2,6))
> 		{
> 			cout<<"Collection #"<<test++<<":"<<endl;
> 			cout<<"Can be divided.\n"<<endl;
> 		}
> 		else
> 		{
> 			cout<<"Collection #"<<test++<<":"<<endl;
> 			cout<<"Can't be divided.\n"<<endl;
> 		}
> 		sum=0;
> 		for(i=0;i<6;i++)
> 		{
> 			cin>>marble[i];
> 			if(marble[i]>limit[i])
> 			{
> 				marble[i]=limit[i]-(marble[i]-limit[i])%2;
> 			}
> 			sum+=marble[i]*(i+1);
> 		}
> 	}
> 	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