让我想到微观经济学的一个题 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
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
34.20 61.7045
1239.5016 29
Problem Author: Magaz Asanov
Problem Source: USU Internal Contest, March 2002
Problem Source: USU Internal Contest, March 2002
Tags: none
)Difficulty: 212
如果你想看解题的一些原代码 可以到这里: http://bbs.oifans.cn/simple/?t427.html
- 让我想到微观经济学的一个题 1200. Horns and Hoofs
- URAL 1200. Horns and Hoofs 枚举+数学
- URAL:1200 Horns and Hoofs
- URAL 1200 - Horns and Hoofs(暴力+剪枝)
- 我想到一个很妙的算法
- 微观经济学
- HashMap与HashTable的区别这个很有用.让我想到二叉树的应用
- 升学——妹妹小鱼儿升学所让我想到的
- 我想到的几句话。
- 微观经济学的学习和理解
- 收藏一个经典图片,太经典了,让我想起了我的历史书!
- 小黑的键盘让我想打字
- 手上的伤让我想起
- 当手里的米越充足!我想到一个故事 这个故事是我们的现况!
- 让griedview显示我想让它显示的
- 微观经济学的特点及其研究对象
- POJ 2328 Guessing Game(一道让我想哭的水题!)
- 我想成为一个出色的网络高手!
- 进程和线程简单区别
- 数组初始化
- android Sdcard挂载
- opengl绘制花托原理
- C# Newtonsoft json
- 让我想到微观经济学的一个题 1200. Horns and Hoofs
- poj 2870 Light Up(dfs+剪枝,写的稀烂)
- 数学之路(3)-机器学习(3)-机器学习算法-最小二乘法与回归[1]
- 解答设计DSP常见的问题
- thinkphp写的验证码不显示
- 一位acmer的竞赛心得
- ios 面试集锦
- 《步步惊芯 软核处理器内部设计分析》火热销售中
- 某大型银行深化系统之十七:性能设计之二