zoukankan      html  css  js  c++  java
  • HDU 5224 Tom and paper(最小周长)

    HDU 5224 Tom and paper(最小周长)

    Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u
     

    Description

    There is a piece of paper in front of Tom, its length and width are integer. Tom knows the area of this paper, he wants to know the minimum perimeter of this paper.
     

    Input

    In the first line, there is an integer T indicates the number of test cases. In the next T lines, there is only one integer n in every line, indicates the area of paper. 
    T<=10,n<= 10^9
     

    Output

    For each case, output a integer, indicates the answer.
     

    Sample Input

    3 2 7 12
     

    Sample Output

    6 16 14
     
     
     
    题解:给出面积求最小周长问题,数学问题
     
    AC代码
    #include<cstdio>
    #include<cmath>
    int main()
    {
        int t,s,n;
        scanf("%d",&t);
        while(t--)
        {
            scanf("%d",&s);
            n=(int)sqrt((double) s);
            while(s%n)
                n--;
            n=2*(n+s/n);
        printf("%d
    ",n);
        }
    return 0;
    }
     
  • 相关阅读:
    C#循环语句练习(三)
    C#循环语句练习(二)
    C#的循环语句(一)
    switch case
    C#的选择语句
    C#的选择语句练习(二)
    C#的选择语句练习(一)
    2015.10.30
    16.缓存(Cache)
    15.禁用ViewState
  • 原文地址:https://www.cnblogs.com/hfc-xx/p/4694098.html
Copyright © 2011-2022 走看看