1209. Construct the Rectangle

1209. Construct the Rectangle

class Solution {
public:
    /**
     * @param area: web page’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;
    }
};
posted @ 2020-01-06 11:35  virgil_devil  阅读(70)  评论(0编辑  收藏  举报