51nod 1283 最小周长

一个矩形的面积为S,已知该矩形的边长都是整数,求所有满足条件的矩形中,周长的最小值。例如:S = 24,那么有{1 24} {2 12} {3 8} {4 6}这4种矩形,其中{4 6}的周长最小,为20。
Input
输入1个数S(1 <= S <= 10^9)。
Output
输出最小周长。
Input示例
24
Output示例
20
水题。。
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

typedef long long LL;
LL S,i,j,minn=0x7fffffff;
int main()
{
    cin>>S;
    for(i=1;i*i<=S;++i)
        if(S/i*i==S)
            minn=min(minn,2*i+2*S/i);
    cout<<minn;
    return 0;
}

 


posted @ 2017-02-09 16:59  杀猪状元  阅读(200)  评论(0编辑  收藏  举报