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
Ravi Chandra: 2015-08-21 20:51:08

Easy prob....TLE Once..Loop modified...AC

maverick_10: 2015-08-16 12:56:52

got TLE using brute force
used quadratic equations got AC in one go

ivuckovic: 2015-08-11 12:39:41

People, read comments! It's easy problem, but with output format restriction and also take care of maximum value of n. I had few WA because of formating and NZEC because int can't hold 10^12 digit number.

viksy: 2015-08-11 09:34:35

Easy problem...green in one go....

satvik: 2015-08-11 09:32:18

Right Alok....easy one...:P

alok singh: 2015-08-11 09:30:11

accepted :p

Last edit: 2015-08-12 06:35:19
Anurag Sharma: 2015-08-02 09:47:48

take care of the word MAXIMUM....cause me 2 wa :P

blackhorse21: 2015-06-01 20:06:07

timelimit is an issue ..can't get the problem for given timelimit.Otherwise all my answers seem to be correct.

Vars: 2015-05-31 15:11:57

Printing format caused me WA... :(

Dhruv k14: 2015-03-07 18:43:42

Format printing error causes WA arrrgghhh


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