1811E.md (1275B)
1 Source: https://codeforces.com/problemset/problem/1811/E 2 3 E. Living Sequence 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 In Japan, the number $4$ reads like death, so Bob decided to build a live sequence. Living sequence $a$ contains all natural numbers that do not contain the digit $4$. $a = [1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, \ldots]$. 22 23 For example, the number $1235$ is part of the sequence $a$, but the numbers $4321$, $443$ are not part of the sequence $a$. 24 25 Bob realized that he does not know how to quickly search for a particular number by the position $k$ in the sequence, so he asks for your help. 26 27 For example, if Bob wants to find the number at position $k = 4$ (indexing from $1$), you need to answer $a_k = 5$. 28 29 Input 30 31 The first line of input data contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases. 32 33 In the only line of each test case, there is a single integer $k$ ($1 \le k \le 10^{12}$) — the position Bob is interested in. 34 35 Output 36 37 For each test case, print on a separate line the number $a_k$ in indexing with $1$. 38 39 Example 40 41 Input 42 43 ``` 44 7 45 46 3 47 48 5 49 50 22 51 52 10 53 54 100 55 56 12345 57 58 827264634912 59 ``` 60 61 Output 62 63 ``` 64 3 65 6 66 25 67 11 68 121 69 18937 70 2932285320890 71 ```