ITRIX_B - Lucky Sequence Again

Lucky Numbers are those numbers made up of prime digits ( 2, 3, 5, 7 ) only . Lucky Numbers contain zero or more copy of these four digits. Lucky sequence is the sequence made of lucky numbers written in ascending order. Print the nth number of the Lucky Sequence.

The first 20 numbers of the lucky sequence will be 2,3,5,7,22,23,25,27,32,33,35,37,52,53,55,57,72,73,75,77…..

Input Format

The First line of the input file contains t which indicate the number of the test cases .Each of the following ‘t’ lines contains an integer ‘n’ .

Constraints

t <= 2000
n <= 10^10 (10  power 10)

Output Format

Output the nth element of the Lucky Sequence (one lucky number per line)

Example

Sample Input:
4
1
3
10
18

Sample Output:
2
5
33
73

Added by:Radhakrishnan Venkataramani
Date:2011-03-27
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:ITRIX 2011

hide comments
2016-04-09 15:11:20 kamran siddique
just switch case is enough ;) so this is in right place.....
2015-03-10 12:34:09 Sue
so nice :)) binary search :))
2014-07-12 10:20:48 Pulkit Singhal
Must be a Classical Question
2013-05-26 09:31:04 ritz
nice question.. but should not be in tutorial i guess...
2012-11-16 19:20:17 :D
It's pretty easy. Someone (author or another moderator) decided it belongs in tutorial, so it stays. I only move medium or harder problems to classical and really trivial ones to tutorial.
2012-11-16 18:38:21 Hussain Kara Fallah
shouldn't be in tutoria ... Please make it classical
@Radhakrishnan
2012-06-03 14:04:56 saket diwakar
Enjoyed to solve it.:)
2011-08-27 17:24:59 Ajey Golsangi
Painful to code the solution.
2011-07-31 09:26:30 neerajcrespo
really nice question.. no need of pre-
computation.
2011-06-24 19:58:58 ~
nice question!!!
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.