PHT - Pigeonhole Tower

no tags 

Pigeon SSNA want to build a tower with some wood walls. Let's describe the tower they want to make:

  1. A Tower can consist of different number of level.
  2. If a tower contain L levels then 1st level must contain L holes, 2nd level L-1, 3rd level L-2 ….. L level contain 1 hole.
  3. Each room contain 3 wood walls.

See the picture below:

3 level 4 level
3 Level Tower 4 Level tower

Now pigeon SSNA has n wood walls. What is maximum number of level he can made.

Input

Input starts with an integer T (≤ 100000), denoting the number of test cases.

Each case starts with a line containing an integer n (1 ≤ n ≤ 1012)

Output

For each case of input you have to print the case number and expected answer.

Example

Input:
2
15
24

Output:
Case 1: 3
Case 2: 4

hide comments
kartikay singh: 2015-02-26 10:24:25

STRICTLY FOLLOW FORMAT:)
got 1WA for not following:(

kelaseek: 2015-02-08 08:50:10

binary search aint doing good

Sayak Haldar: 2015-01-27 14:01:26

time limit is appropiate, a naive solution won't pass...:)

:(: 2015-01-20 10:37:32

Easy math :)

Derek Illchuk: 2015-01-12 21:21:56

Here, scanf/printf vs cin/cout difference: .85sec

Sahil Dua: 2015-01-04 17:16:28

Easy Maths :D

Akash: 2014-12-27 17:19:39

Its working fine in my lappy.
But here WA :/

Can I get help?

Nitin Jain: 2014-12-17 20:31:45

My time is 1.01 but the time limit is 1, still got ac... Anyone knows how??

Last edit: 2014-12-31 11:46:29
:.Mohib.:: 2014-12-17 07:39:04

Finally Got it.... :)

Last edit: 2014-12-25 22:16:10
Satyam Mishra: 2014-12-09 06:45:44

easy one...pure mathematical..


Added by:Ajharul Islam Barid
Date:2014-10-13
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 GOSU
Resource:Own Problem