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.

Input

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).

Output

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.

Example

Input:
1
1

Output:
192

Added by:Matthew Reeder
Date:2006-10-30
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

hide comments
2021-08-21 15:46:08
for JAVA use "long" datatype..
2021-02-19 10:02:44
@fawad That's because your are printing 0 in the front in your 1st solution.
2021-01-08 21:08:48
Ac in 1st time....
2020-07-12 13:41:02
cout << front << last << endl; gave wrong answer, but 1000LL*front+(long long)last gave ac. i wonder why weather it waits for endline or not.
2020-06-21 16:36:44
a fun fact why is that name triple fat ladies!!
well 8 looks like a fat lady you know what i mean :p
2020-05-20 14:03:04
Hint :
Check Pattern
like
1*1*1=1 (NO)
.
.
.
.
192*192*192=7077888 (YES)
.
.
.
442*442*442 = 86350888 (YES)

.
.
.
.
Check The pattern Where cube ends in 888
Then Apply arithmetic progression Formula
-_-
2020-05-06 09:09:26
ac in first go !!
2020-04-30 20:31:26
Just AP.. a=192, d=250;
cout<<192+(k-1)*250;

Last edit: 2020-04-30 20:31:48
2020-04-18 11:10:35
Tips to solve this problem:

- You can try generating all numbers from 1 to say 10000 and check which numbers' cubes would end in 888. With the help of these numbers, you can try finding out the pattern.
- Given in the test case already 1st number ending with 888 is 192. Now, if a number's cube has to end with 888, then (192+x)^3 should end in 888. Since 192 already ends with 888, you need your x to be such that the rest of the terms end in 000s. Try to find the smallest number that could do this to find the pattern.
- For C++ users, use long long int for k and for the answer. You wouldn't need any string manipulations.

Hope this helps! :)
2019-11-11 11:36:11
ac in first go ( happened to me first time), find the pattern
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.