EIGHTS - Triple Fat Ladies

Pattern Matchers have been designed for various sorts of patterns. Mr. HKP likes to observe patterns in numbers. After completing his extensive research on the squares of numbers, he has moved on to cubes. Now he wants to know all numbers whose cube ends in 888.

Given a number k, help Mr. HKP find the kth number (indexed from 1) whose cube ends in 888.


The first line of the input contains an integer t, the number of test cases. t test cases follow.

Each test case consists of a single line containing a single integer k (1 <= k <= 2000000000000).


For each test case, output a single integer which denotes the kth number whose cube ends in 888. The result will be less than 263.




hide comments
rishabhcha: 2016-12-14 10:57:19

little analysis of pattern after that just two lines code in python
try to print first 10 numbers and you will get the pattern

soodan: 2016-12-08 09:24:29

o(1) in c AC in one go !!!

mohitgupta07: 2016-11-16 15:41:49

5 line code with python 2.7 :) :) btw the soln is O(1) for each loop. :) :) Just find when 8 comes at the end in a cube of a number. You'll get the answer :D :D 250!!! ;)

aronzx: 2016-10-30 15:12:34

Did DP first then realized the massive runtime, so noticed something on the console. AC in one go :)

sandeep_4141: 2016-10-22 20:14:59

finally AC...awwww ...use Multiprecision in c++..make it easy problem.

l0gic_b0mb: 2016-09-25 18:28:19

Looks difficult at the first glance, but appearances are deceptive. :P

narutohokage_1: 2016-09-02 04:41:54

Do not start reading comment before doing the program.
I have learnt it and i want to share it with you all. Do not look at comment while doing question.First do it yourself. Try many times and then look at comment because comment dont let you think your brain.

This problem is simple , it was tough but after solving it looks simple. So if someone says a problem is simple , he means that he solved it. Every problem is tough before solving it so don't doubt your ability if you see some problem labeled as easy and you are not able to do it.

Just go through the question not comment , use your own thinking. And write the code , and improve it on EVERY wrong answer and time limit exceeded .Maybe it would take long but you will remember it forever as you did it yourself.

samishamshi: 2016-08-29 22:01:16

I am not able to understand the question can anybody can explain it to me

vsbtechs: 2016-08-23 11:42:43

EASY..but beware :)

rock_lee: 2016-08-22 08:38:27

hi sweatygenius :3

Added by:Matthew Reeder
Time limit:1.197s
Source limit:30000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:Al-Khawarizm 2006