物品 1 2 3 4 5 6
价值 1 2 3 4 5 6
个数 4 7 4 5 9 1
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 |
dp[0] = 1;
物品种类 i= 1
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 |
初值 价值 j=0
价值为v[i=1] t=j +k*v[i] 1 2 3 4
t=0 + 1 * 1
t=0+ 2 * 1
t=0 + 3 * 1
t=0 + 4 * 1
j=0 c[i]
j= 4 3 2 1
j=4
价值为v[i=2] t=j +k*v[i] t 6 8 10 12 14 16 18
t=4 + 1 * 2
t=4 + 2 * 2
t=4 + 3 * 2
t=4 + 7 * 2
c[i]
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
1 | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 |
j=3
价值为v[i=2] t=j +k*v[i] t 5 7 9 11 13 15 17
t=3 + 1 * 2
t=3 + 2 * 2
t=3 + 3 * 2
t=3 + 7 * 2
c[i]
j=2
价值为v[i=2] t=j +k*v[i] t 4 6 8 10 12 14 16
t=2 + 1 * 2
t=2 + 2 * 2
t=2 + 3 * 2
t=2 + 7 * 2
c[i]
j=1
价值为v[i=2] t=j +k*v[i] t 3 5 7 9 11 13 15
t=1 + 1 * 2
t=1 + 2 * 2
t=1 + 3 * 2
t=2 + 7 * 2
c[i]
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 |