Type: Default 1000ms 256MiB

God数

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Description

定义第一类God数为所有数位上的数字均相同的数。

定义第二类God数为满足如下任意一个条件的数:

  • 为第一类God数。
  • tt 为数的位数,则有 t1t-1 位数上的数字相同,且无前导零。

现给定一个 xx,求出 x\ge x 的第一个第 k+1k+1 类好数 yyk{0,1}k\in\{0,1\}

Format

Input

第一行一个整数 xx

第二行一个整数 kk

Output

一行一个整数 yy

Samples

样例 #1

样例输入 #1

700
0

样例输出 #1

777

样例 #2

样例输入 #2

700
1

样例输出 #2

700

Limitation

本题共2020个数据,每个数据 55 分,每个子任务不捆绑

对于所有子任务 1x10171\le x\le 10^{17}k{0,1}k\in\{0,1\}

子任务编号 特殊限制 分值
11 1x1051\le x\le 10^5k=0k=0 1515
22 k=0k=0 2020
33 1x1051\le x\le 10^5 2525
44 无特殊限制 4040

20241128周赛

Not Attended
Status
Done
Rule
IOI
Problem
6
Start at
2024-11-28 16:30
End at
2024-11-28 18:30
Duration
2 hour(s)
Host
Partic.
25