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

那位大牛帮看看啊,实在不知道错那里了

Posted by jsjhoubo1 at 2008-03-09 20:22:22 on Problem 1837
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define s 10000

int x[21],y[21];
int f1[2*s];
int f2[2*s];
int main()
{
	int c,g,i,j,k,min=0,max=0;
	while(scanf("%d%d",&c,&g)==2)
	{
	min=0,max=0;
	for(i=0;i<c;i++)
		scanf("%d",x+i);		
	for(i=0;i<g;i++)
	{
		scanf("%d",y+i);
		min+=y[i],max+=y[i];
	}

	min=min*x[0],max=max*x[c-1];

	memset(f1,0,sizeof(f1));
	memset(f2,0,sizeof(f2));
	for(i=0;i<g;i++)
	{		
		for(j=0;j<c;j++)
		{
			int temp;
			temp=y[i]*x[j];			
			f2[temp+s]++;
			for(k=min;k<=max;k++)
				if(k+temp>=min && k+temp<=max && f1[k+s])
					f2[k+temp+s]+=f1[k+s];
		}
		memcpy(f1,f2,sizeof(f2));
		memset(f2,0,sizeof(f2));
	}
	printf("%d\n",f1[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