Description
"Shall not pass!"
After shouted out That,the Force Staff appered in Caohaha ' s hand.
As we all know,the Force Staff are a Staff with infinity power. If You can use it skillful,it could help you want.
But now,his New Owner,caohaha,is a sorcerers apprentice. He can be only with that staff to send things.
Today,dreamwyy come to caohaha.requesting him send a toy to his new girl friend. It is so far this dreamwyy can only resort to Caohaha.
The the ' the ' to send something are draw a Magic array on a Magic place. The Magic place looks like a coordinate system,and the can draw a segments either in cell sides or on cell Diago Nals. In additional,you need 1 minutes to draw a segments.
If you are want to send something, you are need to draw a Magic array which the isn't smaller than the that. You can make it no deformation,so what really matters is the size of the object.
The Caohaha want to help Dreamwyy but the his/a valuable (to learn to be just as you are), so he want to draw least. However,because of his, Math,he needs your help.
Input
The 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
the
There is a toy of size n, we need to draw a polygon that is not less than it (only along the edge of the lattice or diagonal), each edge or diagonal is a step, ask at least how many steps required.
train of Thought
when the number of steps is even , it is clear that we need to find a rectangle closest to the square (the minimum Length-width difference) to maximize the total area, at which point all the edges are covered diagonally.
Assuming the current step is I, the rectangular area is 2.0 * (I/4) * (I/2-(I/4)).
when the number of steps is odd , we need to take the longest edge apart, and add an edge to increase the area (d * 2-1) * 0.5, on the basis of an even step smaller than it.
According to the number of steps after the second output of the answer can be.
AC Code
#include <bits/stdc++.h> using namespace std; const int MAXN = 1E5+10; typedef __int64 LL; c
onst 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; }