详见: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