|
|
SPOJ Problem Set (tutorial)
3727. Lucky Number
Problem code: KLUCKY
|
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
| Added by: | u.swarnaprakash |
| Date: | 2009-01-17 |
| Time limit: | 2s
|
| Source limit: | 50000B |
| Languages: | All except: ERL TECS JS |
| Resource: | Kurukshetra 09 OPC |
|
|
|
|