ITRIX_B - Lucky Sequence Again

no tags 

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

hide comments
kamran siddique: 2016-04-09 15:11:20

just switch case is enough ;) so this is in right place.....

Sue: 2015-03-10 12:34:09

so nice :)) binary search :))

Pulkit Singhal: 2014-07-12 10:20:48

Must be a Classical Question

ritz: 2013-05-26 09:31:04

nice question.. but should not be in tutorial i guess...

:D: 2012-11-16 19:20:17

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.

Hussain Kara Fallah: 2012-11-16 18:38:21

shouldn't be in tutoria ... Please make it classical
@Radhakrishnan

saket diwakar: 2012-06-03 14:04:56

Enjoyed to solve it.:)

Ajey Golsangi: 2011-08-27 17:24:59

Painful to code the solution.

neerajcrespo: 2011-07-31 09:26:30

really nice question.. no need of pre-
computation.

~: 2011-06-24 19:58:58

nice question!!!


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