裴南平
摘要:回溯法是一种常用的计算机程序设计方法。使用回溯法解决“韩信分油问题”也称“泊松分酒问题”,在算法中保存每一步执行的中间结果,程序扩展前,判斷程序是否进入“循环圈”,程序一旦进入“循环圈”,就不需要往下扩展,开始回溯了。如果能合理设计扩展的条件,防止程序陷入“循环圈”可以提高程序的效率。
关键词:算法;回溯法;泊松分酒;循环圈
中图分类号:TP311 文献标识码:A 文章编号:1009-3044(2017)34-0248-03
Abstract: Backtracking is a commonly used method of computer programming. The use of backtracking method to solve the "Han oil" also known as the " Poisson wine problem", save every step of execution of the intermediate results in the algorithm, the expansion of the program before the procedure to determine whether to enter the "circle", once the program into the circle, do not need to expand down and start backtracking. if can design reasonable expansion conditions to prevent the program into a "circle" can improve the efficienc