(area: i32)
| 2 | |
| 3 | impl Solution { |
| 4 | pub fn construct_rectangle(area: i32) -> Vec<i32> { |
| 5 | let mut ret = vec!(0; 2); |
| 6 | let mut cha = 10000000; |
| 7 | for i in 1..=area/2+1 { |
| 8 | if area % i == 0 { |
| 9 | let tmp = area / i; |
| 10 | let abs = (tmp - i).abs(); |
| 11 | if abs > cha { |
| 12 | continue; |
| 13 | } |
| 14 | cha = abs; |
| 15 | if tmp > i { |
| 16 | ret[0] = tmp; |
| 17 | ret[1] = i; |
| 18 | } else { |
| 19 | ret[0] = i; |
| 20 | ret[1] = tmp; |
| 21 | } |
| 22 | } |
| 23 | } |
| 24 | ret |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | fn main() { |
nothing calls this directly
no outgoing calls
no test coverage detected