#15926. [EC Final 2022] Best Carry Player 2

[EC Final 2022] Best Carry Player 2

[EC Final 2022] Best Carry Player 2

题目描述

Given a positive integer $x$, find the minimum positive integer $y$ such that the number of $\textbf{carries}^1$ of $x+y$ is exactly $k$.

We adds numbers by column addition in base-ten\textbf{by column addition in base-ten}, just like what we normally do in primary school. For example, there are two carries in the following addition.

1^1 which means 进位 in Chinese.

输入格式

The first line contains an integer $T$ $(1\leq T\leq 10^5)$ $-$ the number of test cases.

For each test case, the first line contains two integers x,kx, k (1≤x<1018,0≤k≤18)(1\leq x < 10^{18}, 0\leq k \leq 18).

输出格式

For each test case, output one integer representing the answer in one line. If there is no solution, output $-1$ instead.
4
12345678 0
12345678 5
12345678 18
990099 5
1
54322
999999999987654322
9910

提示

(暂无提示) 标签: P9718|2022|O2优化|数位 DP|ICPC|EC Final

来源

P9718|[EC Final 2022] Best Carry Player 2