# HDU 6154 CaoHaha’s staff （数学）

## 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


## AC 代码

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
typedef __int64 LL;
const int mod = 1e9+7;

double ans[maxn];
void init()
{
double lastL,lastR;
for(int i=4; i<maxn; i++)
{
if(i&1)
{
double d = max(lastL,lastR);
ans[i] = ans[i-1] + (d * 2 - 1) * 0.5;
}
else
{
lastL = i/4;
lastR = i/2 - lastL;
ans[i] = 2.0 * lastL * lastR;
}
}
}

int main()
{
ios::sync_with_stdio(false);
init();
int T;
cin>>T;
while(T--)
{
LL n;
cin>>n;
cout<<lower_bound(ans,ans+maxn,n)-ans<<endl;
}
return 0;
}