01 fractional programming problem

Model 1 issue:

Given \ (n-\) th tuple \ ((VALUE_I, cost_i) \) , where the selected \ (m \) th, \ (VALUE_I \) to select the value obtained for this tuple (non-negative) , \ (cost_i \) is selected price to pay for this tuple (non-negative), provided \ (xi (xi \ in { 0,1}) \) represents the \ (I \) is selected from the bins and is not selected to maximize the formula
\ (R & lt = \ FRAC {\ Sigma VALUE_I} {Xi * \ * cost_i Sigma Xi} \)
\ (. 1 <= n-<= 1000,0 <= K <n-, 0 <= AI <= bi <= 1e9 \)

\(Solution\)

This question is used \ (DP \) What's obvious is not enough,Although I have not tried
The above equation reduces to

\(\Sigma value_i*x_i-\Sigma cost_i*x_i*r=0\),设\(f(r)=\Sigma value_i*x_i-\Sigma cost_i*x_i*r\)

The answer to this function and must be (X-\) \ intersection of the axis, because the { \ (Xi \) } differ, the slope and intercept of this function is different because the \ (\ Sigma value_i * x_i \ ) and \ (\ Sigma cost_i * x_i \) non-negative principle, then our image like this.

Let the answer \ (r \) maximum, we should let the \ (X \) axis maximum intersection

The above equation reduces to \ (\ Sigma x_i (R & lt VALUE_I-cost_i *) \) .

We half line parallel to \ (X-\) the linear axis \ (X = A \) , if the \ (f (a)> 0 \) described further, a line can be shifted to the right, if \ (f (a) <0 \ ) then the description and \ (X \) axis intersection should be on the left, if it shows is that it is equal to \ (r \) maximum.

\(f(a)\)怎么求呢?我们可以用贪心的思想,设\(v_i=value_i-cost_i*r\),然后取\(v_i\)\(m\)大即可,这样确保\(f(a)\)的值尽量大,\(x=a\)尽量往右移,最终知道\(\Sigma v_i=0\),这样就能确保答案的\(r\)最大了。

\(Code\)

还没写就先这样吧

Guess you like

Origin www.cnblogs.com/Liuz8848/p/11266105.html