duanjia4969 2018-03-29 15:34
浏览 57

有关背包问题的棘手的mysql查询

Let's say that we have a user request. That request contains a decimal number. That decimal number is correlated with a table in the database, it is lower than the summary of all values of the fields in a proper column. But the request is not the exact summary of any possible values from that column.

On the other hand - it is not possible to increase that value, but it is possible to reduce any value of the field in this column, so some possible number of values will create a sum, that will match the user's request.

That is the problem, and I don't understand how to solve it. Maybe someone ever has done something similar, and can help me find a way out?

I am not really hoping for this, and I understand that it is a complicated thing even to explain, but I would much appreciate the solution.

$wa = 0.001;
$address = $address;
function recursion($wa)
{
  $resulte = db_select ('Credit_user','c')
  ->fields ('c')
  ->range(0,1)
  ->orderby('cr_ts', 'ASC')
->condition('c.affected','0','=')
->condition('c.amount','0','!=')
 ->execute();
foreach($resulte as $item) {
  global $code = $item->redeem_code;
  global $amounte = $item->amount; 
global $wai = $wa - $amounte;
if ($wai < 0){  
  "production code that should operate with different variations of $amounte and $redeem on last iteration"
  return;
}
elseif ($wai >= 0){  "production code that should operate with different variations of $amounte and $redeem on each iteration"

  return;

} else {
  function recursion($wa - $amounte);
}
}

}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 gg加速器加速游戏时,提示不是x86架构
    • ¥15 python按要求编写程序
    • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
    • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
    • ¥15 opencv图像处理,需要四个处理结果图
    • ¥15 无线移动边缘计算系统中的系统模型
    • ¥15 深度学习中的画图问题
    • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
    • ¥15 Python报错怎么解决
    • ¥15 simulink如何调用DLL文件