让我想到微观经济学的一个题 1200. Horns and Hoofs

来源:互联网 发布:jenkins java api 编辑:程序博客网 时间:2024/06/05 10:30


原文链接:  http://acm.timus.ru/problem.aspx?space=1&num=1200


背景: 最优化问题:  一个人养a, b两种东西,   单只的收益分别为 A,B (输入 可负数) 

成本为 税收( 分别为 A的个数 B的个数的平方  比如各养2 \3 只  税收为 4, 9  共13) 

还有一个限制是  A B的个数总和不能超过K (输入  非负整数) 

求这个最优问题. 


解:   回想起大学时学的微观经济, 还记得边际效用这个概念么?   

数学表示

f(x,y) = xa+yb -xx-yy 表示收益.    那么如果多养一只x

f(x+1,y) = xa+yb -xx - yy +a-2x-1   , 可见变化为    

    delta(x) = a-2x-1

类似地  

   delta(y) = b-2y-1

想一开始你的状态为(0,0)    各表示养A B的数目

那么 可以分别计算 (0,1) (1,0) 的收益 比较大者  , 进一步状态

如此时状态为(1,0)   则分别计算 (1,1) (2,0)  收益  比较大者,  进一步状态

...


直到你向下进一步状态不再取得正收益(  0收益也不取 )  或者你达到了 x+y 上边界. 




1200. Horns and Hoofs

Time limit: 0.25 second
Memory limit: 64 MB
The famous venturer Ostap B. decided to organize a firm "Horns & Hoofs" which will produce horns and hoofs. First of all, Ostap has studied the market, the manufacturing process, and the local conditions.
The calculations showed that each horn would give a profit of A roubles and each hoof would bring B roubles. It must be taken into account that there are similar products in the market already and that horns and hoofs are in a sense interchangeable. Therefore the total amount of produced goods must not exceed K pieces each month, otherwise the excess will not be sold.
Besides, Ostap B. knows that the local racketeers fight monopolism and collect each month for each type of goods a "tax" which is equal (in roubles) to the square of the produced amount. For example, if the firm has produced two horns and three hoofs, then they must pay 4+9=13 roubles.
Having heard about the success of students of the Department of Mathematics and Mechanics in the All-Russian finals of business game Nixdorff Delta, Ostap appealed to the dean's office. He asked to calculate the optimal production volumes for his new firm. The dean is sure that his students will cope with this task.

Input

The first line contains real numbers A and B (−10000 ≤ A,B ≤ 10000) with a two fractional digits precision. These numbers are the profits (in roubles) given by each horn and by each hoof respectively.
The next line contains an integer K which is the maximal number of goods that could be sold each month (1 ≤ K ≤ 10000).

Output

You should output at the first line the maximal possible profit with a two fractional digits precision. The next line should contain the optimal production volumes.
If there are several possible answers, you should output the one with the least amount of horns, and if there is still a tie with the least amount of hoofs.

Sample

inputoutput
34.20 61.7045
1239.5016 29
Problem Author: Magaz Asanov
Problem Source: USU Internal Contest, March 2002
Tags: none  (
hide tags for unsolved problems
)

原创粉丝点击