mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-05 16:36:41 +08:00
17 lines
236 B
Go
17 lines
236 B
Go
package leetcode
|
|
|
|
import "math"
|
|
|
|
func constructRectangle(area int) []int {
|
|
ans := make([]int, 2)
|
|
W := int(math.Sqrt(float64(area)))
|
|
for W >= 1 {
|
|
if area%W == 0 {
|
|
ans[0], ans[1] = area/W, W
|
|
break
|
|
}
|
|
W -= 1
|
|
}
|
|
return ans
|
|
}
|