http://poj.org/problem?id=1837
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
using namespace std;
int dp[21][15001];
int main()
{
int n,m;
int c[50];
int g[50];
int i,k,j;
while(scanf("%d%d",&n,&m)!=EOF)
{
for(i=1;i<=n;i++)
scanf("%d",&c[i]);
for(j=1;j<=m;j++)
scanf("%d",&g[j]);
memset(dp,0,sizeof(dp));
dp[0][7500]=1;
for(i=1;i<=m;i++)
for(k=0;k<=15000;k++)
{
if(dp[i-1][k])
for(j=1;j<=n;j++)
dp[i][k+g[i]*c[j]]+=dp[i-1][k];
}
printf("%d\n",dp[m][7500]);
}
return 0;
}
标签:std,main,1837,int,50,poj,include
From: https://blog.51cto.com/u_16234093/7199349