小编use*_*711的帖子

硬币收藏家的问题

我无法理解包合并算法。谁能一步一步解释包合并算法?我们如何打包以及如何合并?有没有其他最佳算法可以解决硬币收集器的问题?

algorithm

3
推荐指数
1
解决办法
2638
查看次数

这个代码行在这个包合并算法中意味着什么?

我找到了一个算法Package-Merge

Algorithm(I, X) {
    S is empty;
    for all d, Ld list of items having width 2^d;
    while X > 0 loop 
        minwidth = the smallest term in diadic expansion of X; 
        if I=0 then //is empty 
            return “No solution.” ; 
        else 
            d=the minimum such that L is not empty;
            r=2^d; 
            if r > minwidth then 
                return “No solution.”
            else if r = minwidth then 
                Delete the minimum weight ; 
                X= X - minwidth ;
            end if 
            Pd+1=PACKAGE(Ld) ; …
Run Code Online (Sandbox Code Playgroud)

algorithm

-1
推荐指数
1
解决办法
182
查看次数

标签 统计

algorithm ×2