bug:忘了给dp[0]赋值为1了#include<stdio.h>#include<string.h>bool dp[20000000];int h[22];int main(){ int n,b,i,j,sum=0; scanf("%d%d",&n,&b); for(i=1;i<=n;i++) { scanf("%d",&h[i]); sum+=h[i]; } memset(dp,0,sizeof(dp));dp[0]=1; for(i=1;i<=n;i++) { for(j=sum;j&g Read More
背包入门题。。View Code 1 #include<stdio.h> 2 #include<string.h> 3 int dp[12885]; 4 int max(int a,int b) 5 { 6 return a>b?a:b; 7 } 8 int main() 9 {10 int n,m,i,j,w,v;11 while(scanf("%d%d",&n,&m)!=EOF)12 {13 memset(dp,0,sizeof(dp));14 for(i=1;i<=n;i++)15 {16 ... Read More
#include<stdio.h>#include<string.h>int a[510],b[510];int dp[510];int main(){ int t,m,n,i,j; scanf("%d",&t); while(t--) { scanf("%d",&m); for(i=1;i<=m;i++) scanf("%d",&a[i]); scanf("%d",&n); for(i=1;i<=n;i++) scanf("%d&quo Read More