• ppt 例题8 多重背包3


    物品   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

     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  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  0  1  0  1  0  1  0  1  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  0  0  0  0  0  0

     0

  • 相关阅读:
    一.在Linux中for和cat遍历文件内容出现no space
    六.安装jdk(基于Centos7安装)
    五·管理mysql
    四·安装mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz(基于Centos7源码安装)
    ArcGIS api for javascript——图形-增加图形到地图
    ArcGIS api for javascript——图层-创建定制的切片图层类型的图层
    ArcGIS api for javascript——图层-创建WMS图层类型的图层
    ArcGIS api for javascript——地图配置-定制缩放动画,定制缩放框
    ArcGIS api for javascript——地图配置-定制缩放动画
    ArcGIS api for javascript——地图配置-滑动器的刻度线、方向、大小的改变
  • 原文地址:https://www.cnblogs.com/2014acm/p/3919123.html
Copyright © 2020-2023  润新知