MinPerimeterRectangle

 1         /// <summary>
 2         /// Solution
 3         /// 100/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         }

 

posted @ 2015-07-25 22:17  叫我霍啊啊啊  阅读(169)  评论(0编辑  收藏  举报