MinPerimeterRectangle

 1         /// <summary>
 2         /// Solution
 3         /// 通过率 100%
 4         /// </summary>
 5         /// <param name="N"></param>
 6         /// <returns></returns>
 7         public int solution(int N)
 8         {
 9             int result = 0;
10             int sqrtN = Convert.ToInt32(Math.Sqrt(N));
11             for (int i = sqrtN; i > 0; i--)
12             {
13                 if (N % i == 0)
14                 {
15                     result = (i + N / i) * 2;
16                     break;
17                 }
18             }
19             return result;
20         }
时间: 2024-12-16 08:04:30

MinPerimeterRectangle的相关文章