[LeetCode]492. Construct the Rectangle
2017-03-20 21:35
435 查看
[LeetCode]492. Construct the Rectangle
题目描述
思路
对输入的数据取平方根,然后递减遍历,第一个满足整除条件的数即为目标代码
class Solution { public: vector<int> constructRectangle(int area) { vector<int> res; int sq = sqrt(area); while (sq) { if (area % sq == 0) { res.push_back(area / sq); res.push_back(sq); break; } sq--; } return res; } };
相关文章推荐
- LeetCode "492. Construct the Rectangle"
- leetcode 492. Construct the Rectangle
- 【算法作业2】LeetCode 492. Construct the Rectangle
- [LeetCode]492. Construct the Rectangle(构造矩形)
- 【Leetcode】492. Construct the Rectangle
- LeetCode:492. Construct the Rectangle
- LeetCode-492. Construct the Rectangle
- LeetCode 492. Construct the Rectangle (算法)
- leetcode 492 Construct the Rectangle
- [Leetcode] 492. Construct the Rectangle 解题报告
- LeetCode 492. Construct the Rectangle
- python--leetcode 492. Construct the Rectangle
- leetcode 492. Construct the Rectangle
- leetcode 492. Construct the Rectangle
- LeetCode刷题 | 492. Construct the Rectangle
- leetcode 492. Construct the Rectangle(easy)
- leetcode 492. Construct the Rectangle
- LeetCode - 492. Construct the Rectangle
- LeetCode 492 Construct the Rectangle
- LeetCode-492. Construct the Rectangle (Java)