题库练习 Sequence with Digits
← 上一题 下一题 →

A13563 | Sequence with Digits

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Let's define the following recurrence: $$$$a_{n+1} = a_{n} + minDigit(a_{n}) \cdot maxDigit(a_{n}). $$ </p> <p>Here $minDigit(x)$ and $maxDigit(x)$ are the minimal and maximal digits in the decimal representation of $x$ without leading zeroes. For examples refer to notes.</p> <p>Your task is calculate $a\_{K}$ for given $a\_{1}$ and $K$$$.

输入格式

The first line contains one integer $t$ ( $1 \le t \le 1000$ ) — the number of independent test cases.

Each test case consists of a single line containing two integers $a_{1}$ and $K$ ( $1 \le a_{1} \le 10^{18}$ , $1 \le K \le 10^{16}$ ) separated by a space.

输出格式

For each test case print one integer $a_{K}$ on a separate line.

输入输出样例

输入 #1
8
1 4
487 1
487 2
487 3
487 4
487 5
487 6
487 7
输出 #1
42
487
519
528
544
564
588
628
C++ 编辑器
输入
输出