Staircase Problem

3.5

51 votes
Problem

Joy is a short and lazy guy, he uses elevator to reach his flat. But unfortunately elevator is not working today and he became sad. Suddenly God came and made the stairs magical, such that he can jump on it in a magical way. Initially he can take 1 or 2 steps. If he jumps x steps at a time then in the next step he can climb either x or x+1 steps depending on his choice and he must reach exactly on n'th step. Help him find the minimum number of jumps to be made.

INPUT

First line will contain t, total number of test case Next t lines contains n (total number of steps).

0<t<=100

0<n<=10^5

OUTPUT

Minimum steps to reach the stairs.

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?