1209は長方形を構築します

1209は長方形を構築します

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;
    }
};

おすすめ

転載: www.cnblogs.com/virgildevil/p/12155486.html