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

 
贪心
 //2017-08-19
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath> using namespace std; int main()
{
int T, n;
scanf("%d", &T);
while(T--){
scanf("%d", &n);
int len = sqrt(n/);
int area = *len*len;
if(n-area == ){
printf("%d\n", len*);
}else if(n <= area+len-){
printf("%d\n", len*+);
}
else if(n-area <= *len){
printf("%d\n", len*+);
}else if(n <= *(len+)*(len+)-(len++)){
printf("%d\n", len*+);
}
else{
printf("%d\n", (len+)*);
}
} return ;
}

HDU6154的更多相关文章

  1. 【推导】【找规律】【二分】hdu6154 CaoHaha's staff

    题意:网格图.给你一个格点多边形的面积,问你最少用多少条边(可以是单位线段或单位对角线),围出这么大的图形. 如果我们得到了用n条边围出的图形的最大面积f(n),那么二分一下就是答案. n为偶数时,显 ...

随机推荐

  1. swiper4-vue 不使用loop,由最后一张跳到第一张

    <template> <div class="swiper-box"> <div class="swiper-container" ...

  2. 09-04 java 接口

    接口的引出 继续回到我们的猫狗案例,我们想想狗一般就是看门,猫一般就是作为宠物了,对不.但是,现在有很多的驯养员或者是驯兽师,可以训练出:猫钻火圈,狗跳高,狗做计算等. 而这些额外的动作,并不是所有猫 ...

  3. odoo开发笔记 -- odoo web机制浅析

    http://blog.csdn.net/M0relia/article/details/39025947

  4. oracle 11g RAC数据库监听配置相关

    oracle RAC 监听配置基本和单实例的配置相同 11g之后 安装RAC的过程中,不需要执行netca来手动创建监听,在安装集群软件的时候,会自动创建监听程序: 而在DBCA建库的时候,又会自动创 ...

  5. 全网最详细的hive-site.xml配置文件里添加<name>hive.cli.print.header</name>和<name>hive.cli.print.current.db</name>前后的变化(图文详解)

    不多说,直接上干货! 比如,你是从hive-default.xml.template,复制一份,改名为hive-site.xml 一般是 <configuration> <prope ...

  6. 修改Hosts文件提示没有权限怎么办

    解决办法:给host文件赋予权限 1.打开电脑C盘,在目录C:\Windows\System32\drivers\etc 下找到hosts文件 2.右键hosts文件,选择属性 3.点击hosts属性 ...

  7. php -- 文件读写

    ----- 024-file.php ----- <!DOCTYPE html> <html> <head> <meta http-equiv="c ...

  8. 配置Vim的显示样式

    进入用户目录: cd ~ 复制系统的vim配置到用户的目录下: cp -r /usr/share/vim/vimrc ~/.vimrc 如果无法编辑,可能时因为/usr/share/vim/vimrc ...

  9. 卸载或重新安装Redis集群

    卸载或重新安装Redis集群 1.如果需要修改端口号,则需要将原来的Redis各节点的服务器卸载,并重新安装, 卸载服务命令如下: D:/Redis/redis-server.exe --servic ...

  10. 进程间通信 IPC(Inter-Process Communication)

    目录 一.管道 二.FIFO 三.消息队列 四.信号量 五.共享存储 六.网络IPC:套接字   一.管道 管道是进程间通信中最古老的方式,所有UNIX都提供此种通信机制.管道有以下两种局限性: 历史 ...