码迷,mamicode.com
首页 > 其他好文 > 详细

MinPerimeterRectangle

时间:2015-07-25 22:48:30      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:

 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         }

 

MinPerimeterRectangle

标签:

原文地址:http://www.cnblogs.com/HuoAA/p/4676697.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!