Problem L
Undrabarn
Languages
en
is
Jón and his wife, Gunna, just had their first child. Her name is Marta Elísabet, and to no one’s surprise, she is as smart as her parents. Her first word was the first $100$ digits of $\pi $, she knows all programming languages and just solved chess. Even though it may seem impossible, some say she’s smarter than her parents.
Marta likes puzzles. She also likes positive integers that don’t contain the digits $0$ or $8$, which she considers to be boring. She has been writing numbers she doesn’t find boring in increasing order on her bib.
She notices a pattern and asks her dad the following question: Given an integer $K$, what’s the $K$-th number she’ll write down? Jón asks you to calculate this for him since he’s busy changing Marta’s diaper.
Input
One line containing the integer $K$.
Output
A single line containing the $K$-th positive integer containing neither $0$ nor $8$ as a digit.
Scoring
The solution will be tested on input data of varying difficulty and the data is divided into groups as shown in the table below. The solution will then be scored according to how many groups are solved.
Group |
Points |
Constraints |
1 |
50 |
$ 1 \le K \leq 10^{4} $ |
2 |
50 |
$ 1 \le K \leq 10^{12}$ |
Sample Input 1 | Sample Output 1 |
---|---|
5 |
5 |
Sample Input 2 | Sample Output 2 |
---|---|
10 |
12 |
Sample Input 3 | Sample Output 3 |
---|---|
500 |
764 |