492 Construct the Rectangle 构建矩形

详见:https://leetcode.com/problems/construct-the-rectangle/description/

C++:

class Solution {
public:
    vector<int> constructRectangle(int area) {
        int l=sqrt(area),w=sqrt(area);
        while(l*w!=area)
        {
            if(l*w<area)
            {
                ++l;
            }
            else
            {
                --w;
            }
        }
        return {l,w};
    }
};

参考:https://blog.csdn.net/liuchuo/article/details/54669517

原文地址:https://www.cnblogs.com/xidian2014/p/8904088.html

时间: 2024-10-19 00:42:20

492 Construct the Rectangle 构建矩形的相关文章

LeetCode:492. Construct the Rectangle

1 package Today; 2 //LeetCode:492. Construct the Rectangle 3 /* 4 For a web developer, it is very important to know how to design a web page's size. 5 So, given a specific rectangular web page's area, your job by now is to design a rectangular web pa

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 and width W satisfy the following requirements: 1

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 length L and width W satisfy the following requirements: 1

[LeetCode&amp;Python] Problem 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 and width W satisfy the following requirements: 1

LeetCode_492. Construct the Rectangle

492. Construct the Rectangle Easy 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 sat

1209. Construct the Rectangle

1209. Construct the Rectangle class Solution { public: /** * @param area: web pagea€?s area * @return: the length L and the width W of the web page you designed in sequence */ vector<int> constructRectangle(int area) { // Write your code here int st

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 and width W satisfy the following requirements: 1

LeetCode算法题-Construct the Rectangle(Java实现)

这是悦乐书的第243次更新,第256篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第110题(顺位题号是492).对于Web开发人员,了解如何设计网页的大小非常重要.因此,给定一个特定的矩形网页区域,您现在的工作是设计一个矩形网页,其长度L和宽度W满足以下要求: 1.您设计的矩形网页区域必须等于给定的目标区域. 2.宽度W不应大于长度L,这意味着L> = W. 3.长度L和宽度W之间的差异应尽可能小. 您需要按顺序输出您设计的网页的长度L和宽度W. 例: 输入:4

LeetCode:Rectangle Area - 矩形交叉部分的面积

1.题目名称 Rectangle Area(矩形交叉部分的面积) 2.题目地址 https://leetcode.com/problems/rectangle-area/ 3.题目内容 英文:Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined by its bottom left corner and top right corner as shown