1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// @Title: 构造矩形 (Construct the Rectangle)
// @Author: 15816537946@163.com
// @Date: 2021-10-23 18:13:46
// @Runtime: 360 ms
// @Memory: 2 MB
func constructRectangle(area int) []int {
    ret := make([]int,2)
    cur :=math.Sqrt(float64(area))
    
    for i:=area;i>=int(cur);i-- {
        if area%i == 0 {
            v1, v2 := i, area/i
            if v1 >= v2  {
                ret[0], ret[1] = v1, v2
            } else {
                ret[0], ret[1] = v2, v1
            }
        }
    }
    return ret
}