Shinchan and Magical Water Buckets
Shinchan and sweety participating as a team in Infotsav15 coding contest coderush.
She just solved a harder problem and leaves an easy one to Shinchan.
The Task is:
There are N water buckets numbered from 1 to N.The i th bucket needs i*i amount of water to fill completely.
For each i < j in order to fill j th bucket you have to fill i th bucket first.
For a given amount of total water S, You have to calculate the maximum number of bucket N which can be filled according above rule.
Help Shinchan to solve this task.
- The First line contains an integer, T.
- The next T lines contains integer S i.e. amount of total water.
- Output contains T lines containing the maximum number of bucket N which can be filled
- 1 ≤ T ≤ 10000
- 1 ≤ S < 10^16
Input: 3 1 5 8 Output: 1 2 2
For S =1 only one bucket can be filled with 1^1 = 1 litre water.
For S =5 only 2 buckets can be filled with 1^1 + 2^2 with 5 litres of water.
For S =8 only 2 buckets can be filled with 1^1 + 2^2 = 5 litres of water. Rest of the water goes waste
because the 3rd bucket needs 9 litres of water and we only have 3 litres of water remaining.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions