CUBEFR - Cube Free Numbers


A cube free number is a number who’s none of the divisor is a cube number (A cube number is a cube of a integer like 8 (2 * 2 * 2) , 27 (3 * 3 * 3) ). So cube free numbers are 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18 etc (we will consider 1 as cube free). 8, 16, 24, 27, 32 etc are not cube free number. So the position of 1 among the cube free numbers is 1, position of 2 is 2, 3 is 3 and position of 10 is 9. Given a positive number you have to say if its a cube free number and if yes then tell its position among cube free numbers.

Input

First line of the test case will be the number of test case T (1 <= T <= 100000) . Then T lines follows. On each line you will find a integer number n (1 <= n <= 1000000).

Output

For each input line, print a line containing “Case I: ”, where I is the test case number. Then if it is not a cube free number then print “Not Cube Free”. Otherwise print its position among the cube free numbers.

Example

Sample Input:
10
1
2
3
4
5
6
7
8
9
10

Sample Output:
Case 1: 1
Case 2: 2
Case 3: 3
Case 4: 4
Case 5: 5
Case 6: 6
Case 7: 7
Case 8: Not Cube Free
Case 9: 8
Case 10: 9

hide comments
aakash_s: 2016-01-07 20:19:24

The same code in my compiler gave memory overflow ...when i realized there was none other option....i submitted and AC 0.03s

sy_117: 2015-10-23 20:41:23

Nice ques. learnt somthing new !!!!!

prakash_reddy: 2015-10-05 19:33:38

My 100th on Spoj.... prime factorization roxxxxxxxx.... :)

Durgesh Deep: 2015-10-04 20:47:54

Everyone take care about space after :

biggydbs: 2015-09-29 15:45:23

getting wrong answer by applying simple logic subtracting number of cubes till a given number from n and printing result ??

Last edit: 2015-09-29 15:46:05
SangKuan: 2015-07-08 02:41:12

got 2 wa. make it simple,only need sieve

john_iitk123: 2015-07-05 14:17:44

simple use of sieve and recursion...
nice question

Ankush : 2015-06-26 12:44:38

I just modified my Sieve of Eratosthenes :P AC in one go

Rishabh Joshi: 2015-06-11 16:29:30

Same Algo ... AC in C++4.3.2, WA in C#.
:/

karan: 2015-04-22 14:58:20

silly WA :P question can be made better by introducing strict time limit and asking for answers in a range :)

Last edit: 2015-04-22 14:59:19

Added by:Muhammad Ridowan
Date:2011-06-14
Time limit:0.100s-0.939s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Own. For alternate thanks Sayef Azad Sakin