主要是对Math.sqrt()方法的使用。
public class Solution {
public int[] constructRectangle(int area) {
int weight,length;
length=(int) Math.sqrt(area);
weight=(int) Math.sqrt(area);
while(length*weight!=area){
if(length*weight>area){
weight--;
}
else{
length++;
}
}
int []wl={length,weight};
return wl;
}
}