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 zxt at 2008-05-07 22:55:26 on Problem 1837
#include<iostream>
#include<cmath>
using namespace std;
int N[21][15100]={0};
int main()
{
	int n,m;
	int M[20];
	int i,j,k;
	while(scanf("%d %d",&n,&m)!=EOF){
		for(i=0;i<=m;i++)memset(N[i],0,sizeof(N[i]));
	for(i=0;i<n;i++)scanf("%d",&M[i]);
	N[0][7500]=1;
	for(i=1;i<=m;i++){
		int num;
		scanf("%d",&num);
		for(j=0;j<=15000;j++){
			if(N[i-1][j]){
				for(k=0;k<n;k++)N[i][j+num*M[k]]++;
			}
		}
	}
	printf("%d\n",N[m][7500]);
	}
	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