您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

求解线性丢番图方程(有关示例,请参见说明)

求解线性丢番图方程(有关示例,请参见说明)

蛮力递归是一个选项,具体取决于您允许值的大小或数量成为多少。

假设:用户输入(被乘数)始终是不同的正整数。要找到的系数必须是非负整数。

算法:

Of the multiplicands, let M be the largest.
Calculate C=floor(F/M).
If F=M*C, output solution of the form (0,0,...,C) and decrement C
If M is the only multiplicand, terminate processing
Loop from C down to 0 (call that value i)
  Let F' = F - i*M
  Recursively invoke this algorithm:
    The multiplicands will be the current set minus M
    The goal value will be F'
  For each solution output by the recursive call:
     append i to the coefficient list and output the solution
其他 2022/1/1 18:20:08 有625人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶