CF1027C Minimum Value Rectangle
之前做的时候没想出来...现在来数学推导一波。
题意:从n个木棒中选出4个拼成一个矩形,使得 (周长)2/面积 最小。
解:设矩形宽a长b。我们要最小化下面这个式子:

去掉常数,不妨设b = a + len,则化为下式:

取倒数,也就是最大化下式:

显然对于每个确定的a,len越小越好。所以直接取相邻的即可。
好像还有一种推导方法......
原式可直接化为a/b + b/a,这就是个耐克函数双钩函数,让a/b趋近1也就是a=b,所以a和b越接近越好。
CF1027C Minimum Value Rectangle的更多相关文章
- CF1027C Minimum Value Rectangle 贪心 数学
Minimum Value Rectangle time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- CF1027C Minimum Value Rectangle【贪心/公式化简】
https://www.luogu.org/problemnew/show/CF1027C #include<cstdio> #include<string> #include ...
- [Swift]LeetCode963. 最小面积矩形 II | Minimum Area Rectangle II
Given a set of points in the xy-plane, determine the minimum area of any rectangle formed from these ...
- LC 963. Minimum Area Rectangle II
Given a set of points in the xy-plane, determine the minimum area of any rectangle formed from these ...
- 【leetcode】963. Minimum Area Rectangle II
题目如下: Given a set of points in the xy-plane, determine the minimum area of any rectangle formed from ...
- 963. Minimum Area Rectangle II
Given a set of points in the xy-plane, determine the minimum area of any rectangle formed from these ...
- 【LeetCode】963. Minimum Area Rectangle II 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 线段长+线段中心+字典 日期 题目地址:https: ...
- 【CF1027C】Minimum Value Rectangle(贪心,数学)
题意:给定n根木棍,不允许拼接或折断,选择四根组成矩形,求所有合法矩形中周长平方与面积比最小的一个,输出拼成这个矩形的四根木棍 n<=1e6 思路:猜结论:答案必定从相邻的4根中产生 证明见ht ...
- [Swift]LeetCode939. 最小面积矩形 | Minimum Area Rectangle
Given a set of points in the xy-plane, determine the minimum area of a rectangle formed from these p ...
随机推荐
- js实现60秒倒计时效果(使用了jQuery)
今天碰到要实现一个类似那种短信验证码60秒倒计时的需求,好久不写js,有点手生.把代码记录下,方便后续查阅. 这里我用了jQuey,毕竟写起来简洁点.下面直接看效果和代码. 一.效果 ...
- Macaca 基础原理浅析
导语 前面几篇文章介绍了在Macaca实践中的一些实用技巧与解决方案,今天简单分析一下Macaca的基础原理.这篇文章将以前面所分享的UI自动化Macaca-Java版实践心得中的demo为基础,进行 ...
- linux中wget的使用方法介绍
wget是在Linux下开发的开放源代码的软件,作者是Hrvoje Niksic,后来被移植到包括Windows在内的各个平台上.它有以下功能和特点:(1)支持断点下传功能:这一点,也是网络蚂蚁和Fl ...
- post请求参数Json字符串包含数组的校验和处理
传入参数类型 {"aaa":"aaaa","bbb":"bbb","ccc":"ccc&q ...
- pt-online-schema-change的实现原理
pt-online-schema-change用于MySQL的在线DDL. 下面结合官方文档和general log来分析其实现原理. 测试表 mysql> show create table ...
- EF查询百万级数据的性能测试--单表查询
一.起因 个人还是比较喜欢EF的,毕竟不用写Sql,开发效率高,操作简单,不过总是听人说EF的性能不是很好,也看过别人做的测试,但是看了就以为真的是那样.但是实际上到底是怎么样,说实话我真的不知道. ...
- 软件工程第二次作业(JUnit的使用)
初次使用JUnit 感谢学习资源Junit使用的超简单介绍源 一.开发环境及界面截图: 系统 Windows 10 编辑器 eclipse 语言 ...
- Asp.Net_from标签中的Enctype=multipart/form-data作用
ENCTYPE="multipart/form-data"用于表单里有图片上传. <form name="userInfo" method="p ...
- Jq_SetTimeOut
倒计时 59 秒: var t function timedCount() { document.getElementById('txt').value=c ){ c--; }else{ clearT ...
- Win7 64位操作系统连接HP 1010打印机完美解决方案
工作的第一天就遇到问题,新电脑无法连接老式的HP1010打印机,64位Windows7系统无法连接32位XP网络共享打印机,而32位WIN7就可以. 这里分享个简单的解决方法: 先去下载 ...