SPOJ EIGHTS

1030 - Triple Fat Ladies
http://www.spoj.pl/problems/EIGHTS/

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

Explanation
Consider a number $$n = w*10^3 + x*10^2 + y*10 + z$$ and now find the cube of $$n$$. If carry out this operation carefully, you would understand how to solve the problem. Here $$x$$, $$y$$, $$z$$ are digits from 0 to 9, while $$w$$ is any arbitrary number.

By pattern matching: Carefully look at the pattern below: 1. 192 2. 442 3. 692 4. 942 5. 1192 6. 1442 7. 1692 8. 1942 9. 2192 10. 2442 ..... So to generalize the series we can see that difference of every next sequence is 250. So general formula will be: 192+(k-1)*250. That is much easier to find the desired one with time complexity O(1).

Gotchas
Use unsigned long long to contain the answer.

Input
The first line of the input contains an integer $$T$$ representing the number of test cases to follow. Each test case consists of a single line containing a single integer $$1 \le k \le 2000000000000$$. 1 1

Output
192