zoukankan      html  css  js  c++  java
  • HDU6154

    CaoHaha's staff

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 28    Accepted Submission(s): 17


    Problem Description

    "You shall not pass!"
    After shouted out that,the Force Staff appered in CaoHaha's hand.
    As we all know,the Force Staff is a staff with infinity power.If you can use it skillful,it may help you to do whatever you want.
    But now,his new owner,CaoHaha,is a sorcerers apprentice.He can only use that staff to send things to other place.
    Today,Dreamwyy come to CaoHaha.Requesting him send a toy to his new girl friend.It was so far that Dreamwyy can only resort to CaoHaha.
    The first step to send something is draw a Magic array on a Magic place.The magic place looks like a coordinate system,and each time you can draw a segments either on cell sides or on cell diagonals.In additional,you need 1 minutes to draw a segments.
    If you want to send something ,you need to draw a Magic array which is not smaller than the that.You can make it any deformation,so what really matters is the size of the object.
    CaoHaha want to help dreamwyy but his time is valuable(to learn to be just like you),so he want to draw least segments.However,because of his bad math,he needs your help.
     

    Input

    The first line contains one integer T(T<=300).The number of toys.
    Then T lines each contains one intetger S.The size of the toy(N<=1e9).
     

    Output

    Out put T integer in each line ,the least time CaoHaha can send the toy.
     

    Sample Input

    5 1 2 3 4 5
     

     

    Sample Output

    4 4 6 6 7
     

    Source

     
    贪心
     1 //2017-08-19
     2 #include <cstdio>
     3 #include <cstring>
     4 #include <iostream>
     5 #include <algorithm>
     6 #include <cmath>
     7 
     8 using namespace std;
     9 
    10 int main()
    11 {
    12     int T, n;
    13     scanf("%d", &T);
    14     while(T--){
    15         scanf("%d", &n);
    16         int len = sqrt(n/2);
    17         int area = 2*len*len;
    18         if(n-area == 0){
    19             printf("%d
    ", len*4);
    20         }else if(n <= area+len-1){
    21             printf("%d
    ", len*4+1);
    22         }
    23         else if(n-area <= 2*len){
    24             printf("%d
    ", len*4+2);
    25         }else if(n <= 2*(len+1)*(len+1)-(len+1+1)){
    26             printf("%d
    ", len*4+3);
    27         }
    28         else{
    29             printf("%d
    ", (len+1)*4);
    30         }
    31     }
    32 
    33     return 0;
    34 }
  • 相关阅读:
    SQL Server 2016,2014 “无法找到数据库引擎启动句柄”
    SCCM Collection 集合获取计算机最后启动时间
    在Office 365 添加就地保留用户邮箱
    SQL Server数据库log shipping 灾备(Part2 )
    SQL Server数据库log shipping 灾备(Part1 )
    领域驱动设计案例之实现业务3
    领域驱动设计案例之业务实现2
    领域驱动设计案例之业务实现1
    领域驱动设计案例之仓储顶层实现
    领域驱动设计案例之领域层实体与聚合根实现
  • 原文地址:https://www.cnblogs.com/Penn000/p/7397324.html
Copyright © 2011-2022 走看看