【LeetCode】492. Construct the Rectangle【E】【73】

海思3519 arm-hisiv500-linux-交叉编译x264、ffmpeg1.2.12、opencv2.4.9 在x264的源码文件夹下                                                                                                                                                                      /configure --prefix=/h... 阅读详情

For a web developer, it is very important to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose length L and width W satisfy the following requirements:

1. The area of the rectangular web page you designed must equal to the given target area.

2. The width W should not be larger than the length L, which means L >= W.
3. The difference between length L and width W should be as small as possible.
You need to output the length L and the width W of the web page you designed in sequence.

Example:

Input: 4
Output: [2, 2]
Explanation: The target area is 4, and all the possible ways to construct it are [1,4], [2,2], [4,1]. 
But according to requirement 2, [1,4] is illegal; according to requirement 3,  [4,1] is not optimal compared to [2,2]. So the length L is 2, and the width W is 2.

Note:

  1. The given area won't exceed 10,000,000 and is a positive integer
  2. The web page's width and length you designed must be positive integers.

Subscribe to see which companies asked this question.

很简单的 从 根号area 开始遍历,直到找到能被area整除的输就行了

有点类似于判断是不是质数


class Solution(object):
    def constructRectangle(self, area):
        
        l = int(math.ceil(math.sqrt(area)))
        
        while l > 0:
            if area % l == 0:
                return [max(area/l,l),min(area/l,l)]
            l -= 1


CodeForces 1015A-B-C-D-E-F Codefoces 1015 A - Points in Segments CodeForces - 1015A You are given a set of n segments on the axis Ox, each segment has integer endpoints between 1 and m inclusive. Segments may intersect, overlap or even coincide with each other. Each segment is chara 阅读详情

相关推荐

小红书分享链接失效?教你永久保存笔记的2种方法(含API调用技巧)

本文详细解析了小红书笔记链接失效的原因,并提供了两种永久保存笔记的方法,包括短链接转换API调用技巧和本地归档技术。通过Python代码示例和工具推荐,帮助用户实现笔记内容的高效保存和管理,确保珍贵内容不再丢失。

gin88的博客 2769

libx264,交叉编译,报“v4si”的错误,解决方法

libx264,交叉编译,报“v4si”错误

weixin_41700767的博客 631

电子病历编辑器源码(Springboot+原生HTML)

应用场景包括:电子病历书写、体温单录入、全平台信息采集、检验检查报告、不良事件上报等。 此外,电子病历编辑器软件还适用于医生工作站的病历编辑、护士工作站的护理记录输入、PASC/LIS/RIS报告编辑打印、病案首页、出院小结、病程记录、手术记录、各种知情书、康复及精神学科用的量表、临床路径用表单界面等等。 这些应用场景都涉及到了医疗文书编辑的需求,因此电子病历编辑器软件在这些场景中具有广泛的应用价值。

xingchen优快云的博客 3896

【LeetCode】几何学 geometry(共2题)

【587】Erect the Fence 【892】Surface Area of 3D Shapes 转载于:https://www.cnblogs.com/zhangwanying/p/9964512.html

weixin_30662011的博客 139

不用变压器也能联网?手把手教你PHY芯片直连的3种实用方案

本文详细介绍了PHY芯片直连的3种实用方案,帮助开发者在物联网设备中实现更经济、更精简的网络连接设计。通过分析电压驱动型和电流驱动型PHY的核心原理,提供具体的电路配置和优化建议,确保信号质量的同时节省成本和空间。

smartcontract5的博客 333

台达伺服B3驱动器参数的设定和CN1的接法

3. B2的电子齿轮比是直接设定P1-44(分子)和P1-45(分母)就就可以的,但是B3的有个隐藏的细节,就是P1-44的默认值77216不用去更改,这是官方客服说的,需要改的是P1-45这个参数,比如说,我使用的丝杆螺距是5mm的,那么就是以5000脉冲走完5mm为一圈,则就把P1-45设定为5000即可;我的是三菱FX3S系列的PLC,是NPN型的,输出点是24V-作为信号的,所以接41、37,具体可参考B3的。,跟着客服的讲解操作才解决的,以下就是解决方法,希望能够帮到需要的各位。

qq_38681017的博客 1万+

ValueError: n_splits=4 cannot be greater than the number of members in each class.

#[OTC]ValueError: n_splits=4 cannot be greater than the number of members in each class.

河山入梦来的博客 1万+

[比赛]新冠期间饿了么骑士行为预估-数据理解

写在前面 饿了么的比赛的赛题数据理解。 一、骑士行为数据 courier_id 骑士id wave_index 波次index tracking_id 订单id courier_wave_start_lng 波次起始时刻骑士位置 courier_wave_...

Helslie的博客 2943

UVA 492 - Pig-Latin

题意:若单词首字母为辅音放到最后输出,每个单词后加ay注意输入,我本想用gets,但一直ce,只好换成getchar了代码如下:#include <bits/stdc++.h> using namespace std; char x[1000005]; bool A(char c)//判断是否为字母 { return ((c>='a'&&c<='z...

liuxinyu666的博客 941

拆解维修指南:当你的大扭矩电动扳手‘罢工’,如何自己动手排查行星齿轮与谐波传动故障?

本文详细解析了大扭矩电动扳手行星齿轮与谐波传动故障的排查与修复方法。从故障初判、拆解工艺到行星齿轮系统检测、谐波传动维护,提供了一套完整的维修指南,帮助用户快速诊断和解决常见问题,延长工具使用寿命。

weixin_42525582的博客 436

利用 SAP Joule 提升 ABAP 开发效率的前提条件与限制全解析

综上,想要在 ABAP Development Tools 中顺利使用 SAP Joule,既要准备好 BTP、IAS、ABAP 系统与 ADT 的版本与信任链,也要理解许可证、配额、语法范围等限制。只有在这些前提全部满足后,Joule 才能真正发挥生成式 AI 的价值,帮助 ABAP 开发者从繁琐模板中解放出来,把注意力投入在业务创新与 Clean Core 改造之上。未来 SAP 还将扩展中文语境、自动修复建议以及跨系统智能代理等功能,值得持续关注。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 664

Leetcode 492: 构造矩形

题目描述: 作为一位web开发者, 懂得怎样去规划一个页面的尺寸是很重要的。 现给定一个具体的矩形页面面积,你的任务是设计一个长度为 L 和宽度为 W 且满足以下要求的矩形的页面。要求: 1. 你设计的矩形页面必须等于给定的目标面积。 2. 宽度 W 不应大于长度 L,换言之,要求 L >= W 。 3. 长度 L 和宽度 W 之间的差距应当尽可能小。 你需要按顺序输出你设计的页面的...

Jackshijin的博客 426

[QMT量化交易小白入门]-四、如何筛选优质可转债,并进行下单操作

通过上述步骤,成功地使用Python代码完成了可转债的筛选、数据处理和下单操作。当然,这只是一个基础的示例,实际投资中还需要考虑更多因素,如市场环境、资金管理、风险控制等。希望本文能为各位投资者提供一些有价值的参考,助力大家在投资道路上走得更远。

木头大左的博客 1733

C++ error: unknown type name

error: unknown type name '...' 1、未添加头文件; 2、添加了头文件,但该头文件没有添加到工程中; 3、两个头文件中#ifndef~#define~#endif使用的宏相同也会引起此错误;

xy18990的博客 1万+

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

Sequence Modeling With CTC

Sequence ModelingWith CTCurl:https://distill.pub/2017/ctc/ A visual guide to Connectionist Temporal Classification, an algorithm used to train deep neural networks in speech recognition, handwriting

JIN JI 2013.12.24 1901

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

492. 构造矩形 Construct the Rectangle

For a web developer, it is very important to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose length L...

weixin_30361753的博客 199

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

c++编译错误unknown type name xxx

今天在编译时,总是出现一个提示信息 "unknown type name xxx",当时就很奇怪了,明明是我定义的class文件,怎么会出现不识别呢,路径什么的也没问题,在xcode下面也能通过快捷键链接到原文件,但就是不识别,不停提示错误,在网上搜了下,说是可能是因为:如果是报这个错误,多半是你的对象类型没有被识别,检查是不是没有引用对应的库或者头文件在你的文件头部分,还有可能是循环引用导致的,

在路上 7万+

Leetcode 492. Construct the Rectangle 构造矩形

题目:作为一位web开发者, 懂得怎样去规划一个页面的尺寸是很重要的。 现给定一个具体的矩形页面面积,你的任务是设计一个长度为 L 和宽度为 W 且满足以下要求的矩形的页面。要求:1. 你设计的矩形页面必须等于给定的目标面积。 2. 宽度 W 不应大于长度 L,换言之,要求 L >= W 。 3. 长度 L 和宽度 W 之间的差距应当尽可能小。 你需要按顺序输出你设计的页面的长度 L 和...

zhangzhetaojj的博客 598

LeetCode 492. Construct the Rectangle

492. Construct the Rectangle For a web developer, it is very important to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by now is to design a rectang...

柳婼 の blog 1485

python--leetcode 492. Construct the Rectangle

For a web developer, it is very important to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose length L

wenqiwenqi123的博客 733

492. Construct the Rectangle

class Solution(object): def constructRectangle(self, area): """ :type area: int :rtype: List[int] """ l = [] i = math.floor(math.sqrt(area))

guizaijianchic的博客 405

Leetcode #492 Construct the Rectangle

DescriptionFor a web developer, it is very important to know how to design a web page’s size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whos

qq_32796425的博客 346

Python Leetcode(492. 构造矩形)

Python Leetcode(492. 构造矩形) 作为一位web开发者, 懂得怎样去规划一个页面的尺寸是很重要的。 现给定一个具体的矩形页面面积,你的任务是设计一个长度为 L 和宽度为 W 且满足以下要求的矩形的页面。要求: 你设计的矩形页面必须等于给定的目标面积。 宽度 W 不应大于长度 L,换言之,要求 L >= W 。 长度 L 和宽度 W 之间的差距应当尽可能小。 ...

虎口脱险的博客 407

492. Construct the Rectangle [LeetCode]

题目: For a web developer, it is very important to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose l

聪少的博客 583

Leetcode492. Construct the Rectangle最简洁解法

For a web developer, it is very important to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose length L

代码菌的blog 811
上一篇: 【LeetCode】520. Detect Capital【E】【83】
下一篇: 【LeetCode】506. Relative Ranks【E】【50】
Vicky_Vicky_990121
博客等级 码龄14年 23粉丝 187原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值