103362: [Atcoder]ABC336 C - Even Digits

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score: $300$ points

Problem Statement

A non-negative integer $n$ is called a good integer when it satisfies the following condition:

  • All digits in the decimal notation of $n$ are even numbers ($0$, $2$, $4$, $6$, and $8$).

For example, $0$, $68$, and $2024$ are good integers.

You are given an integer $N$. Find the $N$-th smallest good integer.

Constraints

  • $1 \leq N \leq 10^{12}$
  • $N$ is an integer.

Input

The input is given from Standard Input in the following format:

$N$

Output

Print the $N$-th smallest good integer.


Sample Input 1

8

Sample Output 1

24

The good integers in ascending order are $0, 2, 4, 6, 8, 20, 22, 24, 26, 28, \dots$.
The eighth smallest is $24$, which should be printed.


Sample Input 2

133

Sample Output 2

2024

Sample Input 3

31415926535

Sample Output 3

2006628868244228

Input

Output

分数:300分

问题描述

一个非负整数$n$被称为好数字,当它满足以下条件时:

  • $n$的十进制表示中的所有数字都是偶数($0$,$2$,$4$,$6$和$8$)。

例如,$0$,$68$和$2024$都是好数字。

给你一个整数$N$。找到第$N$个最小的好数字。

约束

  • $1 \leq N \leq 10^{12}$
  • $N$是一个整数。

输入

输入将从标准输入中以下格式给出:

$N$

输出

打印第$N$个最小的好数字。


样例输入 1

8

样例输出 1

24

升序排列的好数字是$0, 2, 4, 6, 8, 20, 22, 24, 26, 28, \dots$。
第八个最小的是$24$,应该打印出来。


样例输入 2

133

样例输出 2

2024

样例输入 3

31415926535

样例输出 3

2006628868244228

加入题单

算法标签: