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 start = sqrt(area);
while(area%start != 0 && start<area)
{
start ++;
}
vector<int> res;
res.push_back(start);
res.push_back(area/start);
return res;
}
};
原文地址:https://www.cnblogs.com/virgildevil/p/12155486.html
时间: 2024-10-10 19:15:46