原文链接:  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

input output
34.20 61.70
45
1239.50
16 29
Problem Author: Magaz Asanov
Problem Source: USU Internal Contest, March 2002

Tags: none  ( hide tags for unsolved problems )
Difficulty: 212 
如果你想看解题的一些原代码 可以到这里:    http://bbs.oifans.cn/simple/?t427.html

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

  1. URAL 1200. Horns and Hoofs 枚举+数学

    接触的东西越来越来反而变得不够灵活了,以前碰到的这样的题都要暴力,枚举,两个for循环试试的,今天看到时脑子里接着想暴力会超时的,但是好几个人都200+ms过了,我一直在推导,证明,最后越推越麻烦,一 ...

  2. URAL:1200 Horns and Hoofs

    虽然原题给了250MS,看似很短,其实暴力也是跑能过去的... 应该坑了不少人. #include <iostream> #include <cstdio> #include ...

  3. URAL 1200 Horns and Hoofs 枚举

    设horns和hoofs的数量分别为 x 和 y ,题目要求: 满足 x+y <= K,使得A*x + B*y - x*x - y*y 最大. 枚举 i 从0~K,直接解方程得对称轴 x = ( ...

  4. URAL 1200 - Horns and Hoofs(暴力+剪枝)

    比赛时水过的,现在贴一下正规做法. #include <cstdio> #include <cstring> #include <cstdlib> #include ...

  5. Android实训案例(九)——答题系统的思绪,自己设计一个题库的体验,一个思路清晰的答题软件制作过程

    Android实训案例(九)--答题系统的思绪,自己设计一个题库的体验,一个思路清晰的答题软件制作过程 项目也是偷师的,决心研究一下数据库.所以写的还是很详细的,各位看官,耐着性子看完,实现结果不重要 ...

  6. 内存编址计算题--会一个题能做对一万个题

    系统架构设计师-2010年真题-选择题-8 题目描述: 8.内存按字节编址,利用 8K×4bit 的存储器芯片构成 84000H 到 8FFFFH 的内存,共需( )片. A.6 B.8 C.12 D ...

  7. 有关JAVA考试中数据库的题,javaee期末考试题库,用javaEE编写一个题库系统,要怎么做...

    javaEE数据库简单问题. 你插入2113数据库的时候是把5261它封装为一4102个对象插入的吗?1653 如果封装为一个User对象版的权话(User对象有ID和LEVEL两个属性) Resul ...

  8. 用Unity3D开发一个题库系统

    需求:今日因为项目组人员变动,需要新招一名开发人员.而面试的话会耽误开发进度,进而导致加班,所以准备开发一套随机面试题库,从而帮助我们筛选比较合适的同事. 延伸需求:这套题库的开发思路也适用于延伸到教 ...

  9. 计算机二级c语言最后一个题,全国计算机二级C语言上机题库(答案在最后).doc

    全国计算机二级C语言上机题库(答案在最后) 二级C语言上机考试复习资料,共有50套题目 一.程序填空题 1.给定程序中,函数fun的功能是根据形参i的值返回某个函数的值.当调用正确时, 程序输出: x ...

最新文章

  1. php的环境怎么配置文件,php环境下所有的配置文件以及作用
  2. 在AI领域每月投资一次,全面解析腾讯的人工智能奇招
  3. 2017.5.23 -- 学习记录
  4. Word 技术篇-段落的前后间距单位磅改为行,行改为磅
  5. SpringBoot 源码解析 —— SpringApplication 源码分析
  6. SaaS权限控制:设计思路和表分析
  7. (计算机组成原理)第二章数据的表示和运算-第四节1:算数逻辑单元和电路基本知识以及基本逻辑运算和全加器还有串行、并行加法器
  8. 深入理解 MVC 中的 M 与 C
  9. 小腿抽筋了,按摩承山穴,外加念观世音菩萨是不是迷信
  10. 字节跳动程序媛教你如何刷算法题:面试手撕代码我就没怕过
  11. 基于STM32设计的数字电子秤
  12. oracle 批量修改同义词,Oracle批量创建同义词
  13. python斐波那契数列计算_python计算斐波那契数列
  14. 红芯宣布完成 2.5 亿 C 轮融资,却被网友发现其浏览器安装包解压出 Chrome?
  15. Jenkins教程(2)插件源与常用插件
  16. 大宗商品交易平台:解决期货的最后“一公里”
  17. lol服务器位置2017,LOL怎么转区 LOL转区方法 LOL转区系统2017最新教程
  18. VBA打开已加密的Excel文件
  19. 人工智能数学基础之函数与极限(无穷小与夹逼定理),附视频详解【菜鸟窝出品】
  20. OpenCV:将视频流式传输到网页浏览器/HTML页面

热门文章

  1. SMP,MMP,OLTP ,OLAP
  2. C#实现仿QQ窗口靠边自动隐藏
  3. MES、生产工艺、智能制造、制造执行系统、工厂管理、生产bom、工艺管理、设备维保、资源负荷、甘特图、生产清单、生产排程、模拟排程、计划库、滚动排程、欠产清单、生产任务池、毛坯需求清单、Axure原型
  4. 范仲淹促进经济发展的办法
  5. 中学生可以这样学python_13岁Python开发者写给青少年的Python入门教程
  6. jmeter最大请求数_jmeter支持的最大线程数
  7. 【大数据】十、社会网络图挖掘(Girvan-Newman、拉普拉斯矩阵、Simrank)
  8. 怎么才能提升自己工作能力?
  9. 神雕侠侣手游服务器维修,《神雕侠侣》2021年3月25日更新维护新服开启公告
  10. wxWidgets 自绘窗口