本程序研究了贪心算法,并把此算法用于部分背包问题上,基于C语言实现,达到最优解。所谓贪心算法是指,在对问题求解时,总是做出在当前看来是最好的选择。也就是说,不从整体最优上加以考虑,所做出的仅是在某种意义上的局部最优解。贪心算法不是对所有问题都能得到整体最优解,但对范围相当广泛的许多问题他能产生整体最优解或者是整体最优解的近似解。部分背包问题: 给定一个最大载重量为M的卡车和N种食品,有食盐,白糖,大米等。已知第 i 种食品的最多拥有Wi 公斤,其商品价值为Vi元/公斤,编程确定一个装货方案,使得装入卡车中的所有物品总价值最大。
SHOW FULL COLUMNS FROM `jrk_downrecords` [ RunTime:0.001242s ]
SELECT `a`.`aid`,`a`.`title`,`a`.`create_time`,`m`.`username` FROM `jrk_downrecords` `a` INNER JOIN `jrk_member` `m` ON `a`.`uid`=`m`.`id` WHERE `a`.`status` = 1 GROUP BY `a`.`aid` ORDER BY `a`.`create_time` DESC LIMIT 10 [ RunTime:0.066088s ]
SHOW FULL COLUMNS FROM `jrk_tagrecords` [ RunTime:0.001528s ]
SELECT * FROM `jrk_tagrecords` WHERE `status` = 1 ORDER BY `num` DESC LIMIT 20 [ RunTime:0.002034s ]
SHOW FULL COLUMNS FROM `jrk_member` [ RunTime:0.001175s ]
SELECT `id`,`username`,`userhead`,`usertime` FROM `jrk_member` WHERE `status` = 1 ORDER BY `usertime` DESC LIMIT 10 [ RunTime:0.003060s ]
SHOW FULL COLUMNS FROM `jrk_searchrecords` [ RunTime:0.000838s ]
SELECT * FROM `jrk_searchrecords` WHERE `status` = 1 ORDER BY `num` DESC LIMIT 5 [ RunTime:0.003728s ]
SELECT aid,title,count(aid) as c FROM `jrk_downrecords` GROUP BY `aid` ORDER BY `c` DESC LIMIT 10 [ RunTime:0.014863s ]
SHOW FULL COLUMNS FROM `jrk_articles` [ RunTime:0.001119s ]
UPDATE `jrk_articles` SET `hits` = 2 WHERE `id` = 322892 [ RunTime:0.017910s ]