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:我二进制压缩物品的数组开小了为什么报WA而不是RE啊?

Posted by qp2010 at 2011-05-26 11:57:26 on Problem 1014
In Reply To:Re:我二进制压缩物品的数组开小了为什么报WA而不是RE啊? Posted by:guodongshan at 2010-08-15 10:18:54
> 我也是这样 为什么呢?难道不能用二进制压缩了?
> #include<stdio.h>
> #include<string.h>
> int Ma(int a,int b)
> {
> 	return a>b?a:b;
> }
> int main()
> {
> 	int i,j,k,cas=1,num,sum,ave;
> 	int ans[210003],bag[93];
> 	while(1)
> 	{
> 		k=0;  sum=0;
> 		for(i=1;i<=6;i++)
> 		{
> 			scanf("%d",&num);
> 			sum+=num*i;
> 			for(j=1;j<=num;j*=2)
> 				bag[k++]=j*i;
> 		}
> 		if(sum==0)
> 			break;
> 		printf("Collection #%d:\n",cas++);
> 		if(sum%2)
> 			puts("Can't be divided.");
> 		else{
> 			ave=sum/2;
> 			memset(ans,0,sizeof(ans));
> 			for(i=0;i<k;i++)
> 			{
> 				for(j=ave;j>=bag[i];j--)
> 					ans[j]=Ma(ans[j],ans[j-bag[i]]+bag[i]);
> 			}
> 			//printf("%d\n",ans[ave]);
> 			if(ans[ave]==ave)
> 				puts("Can be divided.");
> 			else
> 				puts("Can't be divided.");
> 		}
> 		puts("");
> 	}
> 	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