#P16213. [ECUSTPC 2025] 十六号塔

    ID: 18228 远端评测题 2000ms 1024MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>2025矩阵加速高校校赛

[ECUSTPC 2025] 十六号塔

Problem Description

Maddy came to a faded tall tower. On the stone tablet under the tower, there was a number nn carved on it.
Maddy found a mechanism on a stone nearby. She pressed it and found that the number on the tablet changed as follows:

  • Split the decimal representation of nn into digits, square each digit, and then concatenate them in the original order to form a new number nn'.

Maddy was curious. She pressed the mechanism mm times. She recorded the original nn and the results after pressing it these mm times, for a total of m+1m+1 numbers: n,n,n,,n(m)n, n', n'', \dots, n^{(m)}.
Maddy wants to know the value ansans of the sum of these m+1m+1 numbers modulo 99. Please help her compute it.

Input Format

The first line contains an integer TT (1T1031 \le T \le 10^3), the number of test cases.
For each test case, the only line contains two integers nn and mm (1n,m1091 \le n, m \le 10^9), representing the number carved on the tablet and the number of times Maddy pressed the mechanism.

Output Format

For each test case, output one integer ansans on a single line, representing the sum of the above results modulo 99.

4
1 100
2 4
74700 1
2279 1
2
6
6
5

Hint

Sample 1 Explanation

For the 1st sample case, after pressing the mechanism, 11 always stays 11. Each result is 11, so the total sum is 1×101=1011 \times 101 = 101, and the modulo is 101mod9=2101 \bmod 9 = 2.
For the 2nd sample case, the number changes as follows: 242 \to 4, 4164 \to 16, 1613616 \to 136, 1361936136 \to 1936. The sum of these 5 numbers modulo 99 is $(2 + 4 + 16 + 136 + 1936) \bmod 9 = 2094 \bmod 9 = 6$.
For the 3rd sample case, the number changes as follows: 747004916490074700 \to 49164900.
For the 4th sample case, the number changes as follows: 22794449812279 \to 444981.

Hint

Taking modulo 99 means the remainder after dividing the number by 99.

Translated by ChatGPT 5