492 Construct the Rectangle 构建矩形

Posted lina2014

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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

以上是关于492 Construct the Rectangle 构建矩形的主要内容,如果未能解决你的问题,请参考以下文章

492. Construct the Rectangle

492. Construct the Rectangle

492. Construct the Rectangle

492. Construct the Rectangle

LeetCode_492. Construct the Rectangle

492. Construct the Rectangle(LeetCode)