美文网首页
492. Construct the Rectangle

492. Construct the Rectangle

作者: 安东可 | 来源:发表于2018-04-11 21:32 被阅读11次

492. Construct the Rectangle
【思路】

  • 矩形计算,也就是将一个数拆分成两个数相乘;两个数尽可能小,也就是接近;
    vector<int> 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

      本文链接:https://www.haomeiwen.com/subject/bdzzhftx.html