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

,奇怪了,为什么已知wa,哪位高手帮忙看一下???

Posted by 08060029 at 2009-07-30 19:46:07 on Problem 1014
#include<iostream>
#include<memory.h>
using namespace std;
int stone[7],max1,mid;
int opt[60001];
int DFS()
{
	int i,j,k;
	for(i=1;i<=6;i++)
	{
		if(stone[i])
		{	
			for(j=0;j<=max1;j++)
			{
				if(opt[j])
				{
					for(k=1;k<=stone[i];k++)
					{
						if(opt[mid])
							return 1;
						if(j+i*k>mid)
							break;
						if(opt[j+i*k]==0)
							opt[j+i*k]=1;
					}		
				}
			}
			max1=max1+i*stone[i];
			if(max1>mid)
				max1=mid;
		}
	}
	return 0;
}
int main()
{
	int i,CASE=0;
	while(cin>>stone[1])
	{
		mid=stone[1];
		CASE++;
		for(i=2;i<=6;i++)
		{
			cin>>stone[i];
			mid+=stone[i]*i;
		}
		if(mid==0)
			break;
		if(mid%2)
		{
			cout<<"Collection #"<<CASE<<":\nCan't be divided.\n\n";
 			continue;
		}
		else 
		{
			max1=0;
			mid=mid/2;
			memset(opt,0,sizeof(opt));
			opt[0]=1;
			if(DFS())
				cout<<"Collection #"<<CASE<<":\nCan be divided.\n\n";
			else cout<<"Collection #"<<CASE<<":\nCan't be divided.\n\n";
		}
	}
	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