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. 关于 kali linux

    2.更新系统:首先更换一个速度快点的国内源(1) lsb_release -a先看你的版本,是Rolling还是其他什么(2) leafpad /etc/apt/sources.list(源的默认文件 ...

  2. [Visual Studio] 记一次排错:打不开 Nuget 包管理器里的安装package页面,无法 安装 / 恢复 包

    出差一阵子PC很久没用了, 回来在用Visual Studio (2017) 的时候, 工程里无法安装Package了  >_<    --- 也不知道电脑做了什么?--- Nuget包管 ...

  3. postgresql-清空shared_buffers

    清空os缓存,shared_buffers 1.停止数据库 pg_ctl -m fast -D /pgdata stop 2.清空高速缓存前尝试将数据刷新至磁盘 sync 3.清空缓存 echo 3 ...

  4. Linux学习系列之一:在centos 7.5上安装nginx 以及简单配置

    说到Linux我们都知道那是相当相当得重要得啊,在计算机这个行业,开发运维都是离不开它得.我作为一个准毕业生,智商可能不太够,只能自己笨鸟先飞,自己操作起来咯.俗话说的好,好记性不如难笔头嘛.而且ng ...

  5. POJ 2492

    #include<iostream> #include<stdio.h> #define MAXN 2050 using namespace std; int pre[MAXN ...

  6. 剑指offer二十之包含min函数的栈

    一.题目 定义栈的数据结构,请在该类型中实现一个能够得到栈最小元素的min函数. 二.思路 用一个栈dataStack保存数据,用另外一个栈minStack保存依次入栈最小的数.每次元素存入minSt ...

  7. 图片训练:使用卷积神经网络(CNN)识别手写数字

    这篇文章中,我们将使用CNN构建一个Tensorflow.js模型来分辨手写的数字.首先,我们通过使之“查看”数以千计的数字图片以及他们对应的标识来训练分辨器.然后我们再通过此模型从未“见到”过的测试 ...

  8. Dubbo--002--例子程序

    虽然项目中用到了dubbo,还是想自己玩玩写个demo.百度一搜,关于dubbo的helloworld基本都是在windows上做的.现在在Linux上玩一下. 环境准备: jdk版本:1.7 服务器 ...

  9. NSLog()输出函数集格式字符

    nslog()强大的功能这里就不多说了,笔者从c#转过来,难免会有些陌生.在c#中用format("{0}",xx}来进行占位,下面就来讲讲在oc中的格式字符; d:带符号的十进制 ...

  10. Spring Boot + Spring Cloud 实现权限管理系统 后端篇(九):代码整理优化

    工程规划 为了统一配置和代码解耦,我们对代码重新进行了整理和规划. 重新规划后,代码结构如下: kitty-pom: 统一管理 Maven 版本,打包配置 kitty-common: 公共代码模块,主 ...