zoukankan      html  css  js  c++  java
  • 1283 最小周长

    1283 最小周长

    基准时间限制:1 秒 空间限制:131072 KB
    一个矩形的面积为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 <cstdio>
    #include <cmath>
    int main()
    {
        int n;
        while(scanf("%d", &n) != EOF)
        {
            int B=n;
            int Q= ceil(sqrt(n*1.0));
            int resert;
            for(int i=Q; i>= 1; i--)
            {
                if(B%i==0 && B/Q <=n)
                {
                    resert= i;
                    break;
                }
            }
            printf("%d
    ", resert*2+(B/resert)*2);
        }
        return 0;
    } 
  • 相关阅读:
    C++(函数默认参数)
    C++(引用六)
    C++(引用五)
    C++(引用四)
    C++(引用三)
    C++(引用二)
    C++(引用一)
    划水。。。
    2019.11.7
    lyc——2019.10.31
  • 原文地址:https://www.cnblogs.com/ceal/p/5468078.html
Copyright © 2011-2022 走看看