102342: [AtCoder]ABC234 C - Happy New Year!
Description
Score : $300$ points
Problem Statement
Among the positive integers that consist of $0$'s and $2$'s when written in base $10$, find the $K$-th smallest integer.
Constraints
- $K$ is an integer between $1$ and $10^{18}$ (inclusive).
Input
Input is given from Standard Input in the following format:
$K$
Output
Print the answer as an integer.
Here, the exact value must be printed as an integer, even if it is big. Exponential notations such as 2.34e+22
, for example, or unnecessary leading zeros such as 0523
are not allowed.
Sample Input 1
3
Sample Output 1
22
The positive integers that consist of $0$'s and $2$'s when written in base $10$ are $2,20,22,\dots$ in ascending order.
The $(K=)$ $3$-rd of them, which is $22$, should be printed.
Sample Input 2
11
Sample Output 2
2022
Sample Input 3
923423423420220108
Sample Output 3
220022020000202020002022022000002020002222002200002022002200
Note that the exact value of the answer must be printed as an integer, even if it is big.
Input
题意翻译
给定 $K$,询问在所有仅有数码 $0,2$ 组成的数字中,第 $K$ 小的数是多少。Output
分数:300分
问题描述
当用十进制表示时,找出由0和2组成的正整数中的第K小的数。
限制条件
- K是一个在1到1018(含)之间的整数。
输入
输入从标准输入按以下格式给出:
$K$
输出
将答案作为一个整数打印出来。
即使数值很大,也要精确地以整数形式打印。不允许使用如2.34e+22
这样的指数表示法,或者如0523
这样的不必要的前导零。
样例输入1
3
样例输出1
22
当用十进制表示时,由0和2组成的正整数按升序排列为$2,20,22,\dots$。
其中的第$(K=)$ 3个数,即$22$,应该被打印出来。
样例输入2
11
样例输出2
2022
样例输入3
923423423420220108
样例输出3
220022020000202020002022022000002020002222002200002022002200
请注意,即使数值很大,也要精确地以整数形式打印出答案。