#abc336c. C - Even Digits

C - Even Digits

Score: 300300 points

问题描述

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

  • nn 的十进制表示中,所有数字都是偶数(00, 22, 44, 66, 和 88)。

例如,00686820242024 都是好整数。

给定一个整数 NN,请找出第 NN 小的好整数。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

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

  • All digits in the decimal notation of nn are even numbers (00, 22, 44, 66, and 88).

For example, 00, 6868, and 20242024 are good integers.

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

Constraints

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

Input

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

NN

Output

Print the NN-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,0, 2, 4, 6, 8, 20, 22, 24, 26, 28, \dots.
The eighth smallest is 2424, which should be printed.

Sample Input 2

133

Sample Output 2

2024

Sample Input 3

31415926535

Sample Output 3

2006628868244228

update @ 2024/3/10 01:25:04