我正在制作一个程序,使用动态编程来决定如何在DVD中分发一些文件(电影),以便它使用最少数量的DVD.
经过深思熟虑之后我决定一个好方法就是看看每个可能的小于4.38 GB的电影组合(DVD的实际大小)并选择最大的一个(即浪费最少空间的电影)并以最有效的组合删除电影并重复播放,直到电影耗尽.
问题是我不知道如何循环所以我可以找出每个可能的组合,因为电影的大小不同,所以不能使用特定数量的嵌套循环.
伪代码:
Some kind of loop:
best_combination=[]
best_combination_size=0
if current_combination<4.38 and current_combination>best_combination_size:
best_combination=current_combination
best_combination_size=best_combination_size
print(best_combination)
delete best_combination from list_of_movies
Run Code Online (Sandbox Code Playgroud)
第一次发一个问题..对我这么简单!提前致谢
PS我想出了一种使用Dijkstra的方法,我觉得它很快但不是内存友好的.如果有人有兴趣,我很乐意讨论它.
当我启动 docker for windows 时,内存使用量几乎增加了 6 GB 的 25%(即 1.5 GB),甚至没有运行容器。我在任务管理器中看不到 docker 进程,但我通过查看运行 docker for windows 程序之前和之后的内存使用情况%来计算内存使用情况。我正在运行 Windows 10。如何防止 docker 吃掉所有这些内存。