KLUCKY - Lucky Number

no tags 

The Kurukshetra OPC team observed that many online programming contests have a problem titled "Lucky Number". So we decided to have one in KOPC too.

We define the Lucky sequence as the infinite sequence of all integers, in ascending order, that can represented as any positive integer power of 5 (i.e. 5k where k is a positive integer) or as a sum of distinct positive integer powers of 5 (i.e. 5a1 + 5a2 + 5a3 + ... , where a1, a2, a3, ... are distinct positive integers). All the numbers in the lucky sequence are called lucky numbers. The first few lucky numbers are 5, 25, 30, 125, 130, 150, ...

Given n your task is to find the nth lucky number.

Input

First line of input contains an integer t, t ≤ 200, representing the number of test-cases. Then t lines follow each containing one integer n, 1 ≤ n ≤ 8000.

Output

For each test case output the nth lucky number on a separate line. Answers will fit in a 32-bit signed integer.

Example

Input:
4
1
2
3
9

Output:
5
25
30
630

hide comments
ariel_23052005: 2018-04-06 13:09:25

Why I Have ERROR "runtime error (SIGSEGV)"?
What's wrong?
I only use array str [8000]

Daksh Taparia: 2014-01-30 18:25:45

Super Awesome Problem :)

Abdul Ghofur: 2010-11-05 02:18:42

Last edit: 2010-11-05 02:19:25
Mark: 2010-09-25 08:38:32

Actually, nevermind. After re-reading the problem I found my error...

Mark: 2010-09-25 07:21:58

Is the example wrong? I think it should be 650 for case input=9, as 630 is for case: input=8..


Added by:Swarnaprakash
Date:2009-01-17
Time limit:1.5s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:Kurukshetra 09 OPC