# 题目

{% fold 点击显/隐题目 %}

"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.

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).

Out put T integer in each line ,the least time CaoHaha can send the toy.
5 1 2 3 4 5
4 4 6 6 7
{% endfold %}

# 题解

• 周长越大围的面积也越大,也即尽可能多用`√2`
• 周长相同的情况下越圆面积越大

# 代码

{% fold 点击显/隐代码 %}```cpp CaoHaha's staff https://github.com/OhYee/sourcecode/tree/master/ACM 代码备份
#include
#include
using namespace std;

const int maxn = 150000;

long long f[maxn];
void calc() {
f[0] = f[1] = f[2] = f[3] = 0;
f[4] = 2;
f[5] = 2;
f[6] = 4;
f[7] = 5;
for (long long i = 2; i < (maxn / 4) - 1; ++i) {
f[i * 4] = i * i * 2;
f[i * 4 + 1] = f[i * 4] + (i + i - 1) / 2;
f[i * 4 + 2] = f[i * 4] + i * 2;
f[i * 4 + 3] = f[i * 4 + 2] + (i + i + 1) / 2;
}
}

int main() {
// freopen("out.txt","w",stdout);
int T;
scanf("%d", &T);
calc();

``````/*
for (int i = 1; i < 100; ++i) {
printf("%d %d\n", i, lower_bound(f, f + maxn, i) - f);
}
*/

while (T--) {
long long n;
scanf("%I64d", &n);
printf("%d\n", lower_bound(f, f + maxn, n) - f);
}

return 0;
``````

}

`{% endfold %}`