Submit | All submissions | Best solutions | Back to list |
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
|
||||||||||||||
2015-05-20 20:28:50 biswas
solution hidden in the word "PATTERN"...Think Think |
||||||||||||||
2015-05-18 07:47:31 pk
nice question... Ac in first go... :) |
||||||||||||||
2015-04-18 16:23:06 John Jost
I feel dirty... Did it initially with an entirely too slow algorithm but that let me see the pattern which made this a trivial problem. |
||||||||||||||
2015-04-16 16:54:19 Pradd
AC on second.. Don't forget to use long long in C.. For large numbers, instead of segmentation fault you got a weird output which gives WA.. |
||||||||||||||
2015-04-14 08:11:43 hareesh
AC on first go :) @arjun : thanx for the pattern |
||||||||||||||
2015-03-27 19:41:34 arjun
Test Cases: 4 1 2 3 4 192 442 692 942 I did in O(1) for single test case. Observe the pattern in the op. U will definitely get it. Stills Doubts, then contact Spoj forum. Last edit: 2015-03-27 20:16:36 |
||||||||||||||
2015-03-26 08:02:05 Tony T.
For c++ I had to use long long to meet the 2000000000000 limit |
||||||||||||||
2015-03-15 17:24:11 Maverick
those using JAVA, there's no need to use BigInteger. long is more than enough.Just think. Last edit: 2015-03-15 17:24:32 |
||||||||||||||
2015-03-07 10:32:01 Abhishek Naik
Very easy. Here is a clue, from the question above: 'Mr. HKP likes to observe patterns in numbers'. Think over it, and you'll get the answer. |
||||||||||||||
2014-12-15 19:52:23 Sabarish
Easy but tricky. Testing sequentially is the name of the game here |