492. Construct the Rectangle

492. Construct the Rectangle
【思路】

  • 矩形计算,也就是将一个数拆分成两个数相乘;两个数尽可能小,也就是接近;
    vector constructRectangle(int area) {
        int mid = sqrt(area);
        for(int i = mid; i>0; i--)
            if (!(area%i))
                return {area/i, i};
    }

你可能感兴趣的:(492. Construct the Rectangle)