1 #include<cstdio> 2 #include<cstring> 3 using namespace std; 4 int f[25][15010]; 5 int c[25],g[25]; 6 int C,G; 7 int main() 8 { 9 scanf("%d%d",&C,&G); 10 for (int i=1;i<=C;i++) scanf("%d",&c[i]); 11 for (int i=1;i<=G;i++) scanf("%d",&g[i]); 12 memset(f,0,sizeof(f)); 13 f[0][7500]=1; 14 for (int i=1;i<=G;i++) 15 for (int j=-7500;j<=7500;j++) 16 if (f[i-1][j+7500]>0) 17 { 18 for (int k=1;k<=C;k++) 19 f[i][j+c[k]*g[i]+7500]+=f[i-1][j+7500]; 20 } 21 printf("%d\n",f[G][7500]); 22 return 0; 23 }
时间: 2024-11-08 22:06:54