标签:
Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 11029 | Accepted: 6846 |
Description
Input
Output
Sample Input
2 4 -2 3 3 4 5 8
Sample Output
2
Source
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<algorithm> #include<cstdlib> using namespace std; int c,g,p[24],w[24],f[24][20010]; int main() { while(scanf("%d%d",&c,&g)!=EOF) { memset(f,0,sizeof(f)); f[0][10000]=1; for(int i=1;i<=c;i++) scanf("%d",&p[i]); for(int i=1;i<=g;i++) scanf("%d",&w[i]); for(int i=1;i<=g;i++) { for(int j=0;j<=20000;j++) { for(int k=1;k<=c;k++) { if(j>=p[k]*w[i]) f[i][j]+=f[i-1][j-p[k]*w[i]]; } } } printf("%d\n",f[g][10000]); } return 0; }
标签:
原文地址:http://www.cnblogs.com/a972290869/p/4223403.html