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 ...
随机推荐
- JSON传输数组的基本操作
目标JSON结果如下: 生成JSON的的过程如下: Document document; Document::AllocatorType& allocator = document.GetAl ...
- PostgreSQL安装和配置---Ubuntu
PostgreSQL安装和配置---Ubuntu
- 用C++实现一个Brainfuck解释器
Brainfuck是一种极小化的计算机语言,只含有8种运算符,由于fuck在英语中是脏话,这种语言有时被称为brainfck或brainf**,甚至被简称为BF.正如它的名字所暗示,brainfuck ...
- vuex实践之路——笔记本应用(三)
Actions Action 类似于 mutation,不同在于: Action 提交的是 mutation,而不是直接变更状态. Action 可以包含任意异步操作. 让我们来注册一个简单的 act ...
- 警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context}Setting property 'source' to 'org.eclipse
当你用Eclipse运行web项目的时候,你就会看到控制台出现:WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Set ...
- python基础篇----基本数据类型
bit #bit_length 当前数字的二进制,只用用n位来表示a = 123b = a.bit_length()print(b)#==>7
- [SHELL]输入输出重定向与管道
一 . 输出重定向(将命令的输出重定向到文件): ls -al > test 以覆盖的方式写入 ls -al >> test 以追加的方式写入 二 . 输入重定向(将文件的内容重定向 ...
- 微软职位内部推荐-Software Engineer-Sharepoint
微软近期Open的职位: SharePoint is a multi-billion dollar enterprise business that has grown from an on-prem ...
- linux第三章学习笔记
第三章 进程管理 进程是Unix操作系统抽象概念中最基本的一种. 进程管理是所有操作系统的心脏所在. 一.进程 1. 进程是处于执行期的程序.除了可执行程序代码,还包括打开的文件.挂起的信号.内核内部 ...
- java实验报告三
实验三 敏捷开发与XP实践 一.实验内容 1. XP基础 2. XP核心实践 3. 相关工具 二.实验步骤 (一)敏捷开发与XP 软件工程是把系统的.有序的.可量化的方法应用到软件的开发.运营和维护上 ...