307420: CF1355A. Sequence with Digits
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Sequence with Digits
题意翻译
- 数列$a_{1…n}$,满足 $$a_{n+1}=a_{n}+ \operatorname{minDigit}{(a_{n})} \cdot \operatorname{maxDigit}(a_n)$$ - 其中,$\operatorname{minDigit} \operatorname{maxDigit}$ 代表一个十进制数中**每一位**的最小值和最大值,例如$\operatorname{minDigit}(21) = 1,\operatorname{maxDigit}(21)=2$。 - 给出 $a_1$,你需要求出 $a_k$的值 - **本题多组数据**,$1\le a_1 \le10^{18},1 \le k \le 10^{16}$。题目描述
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