problem
solution1:
class Solution {public: vector constructRectangle(int area) { int r = sqrt(area); while(area % r != 0) r--; return {area/r, r}; }};
solution2:
class Solution {public: vector constructRectangle(int area) { int r = 1; for(int i=1; i*i <=area; i++) { if(area % i == 0) r = i; } return {area/r, r}; }};
参考
1. ;
2. ;
完