分油问题回朔法c语言算法,用回溯法求“韩信分油”问题所有解

本文介绍了如何使用回溯法解决“韩信分油问题”,也称为“泊松分酒问题”。通过设计合理的扩展条件,避免程序陷入“循环圈”,可以提高求解效率。C语言实现的程序可以找到该问题的17个不同解,最长解需要17步,最短解仅需8步。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

裴南平

摘要:回溯法是一种常用的计算机程序设计方法。使用回溯法解决“韩信分油问题”也称“泊松分酒问题”,在算法中保存每一步执行的中间结果,程序扩展前,判斷程序是否进入“循环圈”,程序一旦进入“循环圈”,就不需要往下扩展,开始回溯了。如果能合理设计扩展的条件,防止程序陷入“循环圈”可以提高程序的效率。

关键词:算法;回溯法;泊松分酒;循环圈

中图分类号: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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值