| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
这样做为什么错了,不是背包吗,难道有特殊数据#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator