VECTAR4  Changus Final Battle
Try the tutorial version first : Changus Big Battle : http://www.spoj.com/problems/VECTAR2/
Changu is going to fight a battle. He is powerful but he has a few limitations. If he kills x enemies on a particular day, then he can only kill x1 or x or x+1 enemies on the next day. And also, he can kill no more than 1 enemy on the last day of battle. Given N, the number of enemies he has to kill to end the battle, you have to calculate the minimum number of days required for Changu to finish the battle, keeping in mind his limitations. He starts on day 1 by x=1, i.e. killing one enemy.
Input
The first line contains an integer T denoting the number of test cases.
Each of the next T lines contain an integer N.
Output
T lines : Minimum number of days required for each test case.
Constraints
1 <= T <= 10^5
1 <= N <= 10^18
Example
Input: 3 4 1 9 Output: 3 1 5
Explanation
Case 1 : 1 + 2 + 1
Case 2 : 1
Case 3 : 1 + 2 + 3 + 2 + 1
Note: Test files have been updated. Solutions will be rejudged.
hide comments
sandeep_4141:
20170113 18:21:11
in vectar2 1st I got TLE but thinking deeply got AC in both question same code !!! Nice one O(1),yes:) 

madhavgaba:
20170111 19:28:22
Last edit: 20170114 17:33:31 

dwij28:
20161007 22:21:19
Are the testcases weak ? I mean VECTAR2 is the tutorial problem with the same question but smaller constraints and my solution for VECTAR2 runs faster than that for VECTAR4, which is essentially the same code except for replacing int by long long . Anyways nice question. Made me think for a while. O(1) it is :) Last edit: 20161007 22:22:10 

cegprakash:
20160728 10:09:33
Weak test cases. Worst case inputs are not in input file. My initial very bad code passed too!


iharsh234:
20160727 21:29:42
@Piyush Kumar please remove spoiler comments.


avisheksanvas:
20160708 10:29:19
<spoiler removed> Last edit: 20160728 15:01:16 

azam_9:
20160702 21:59:18
nice problem..<3..


wesolyfoton:
20160626 02:59:20
@tarungupta1956: me too :P +1/1 in wrong order :P and I was looking for mistake for 15 minutes :P 

tarungupta1956:
20160622 20:22:04
took me 10 wa to realize a stupid mistake\:


Akshat Jain:
20160622 07:05:10
really nice

Added by:  Piyush Kumar 
Date:  20160620 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 GOSU JSMONKEY 