Universal Cup Judging System

Universal Cup

時間限制: 3 s 記憶體限制: 1024 MB 總分: 100 难度: [顯示]
统计

Дано положительное целое число $x$. Найдите минимальное положительное целое число $y$ такое, что количество переносов$^1$ при сложении $x + y$ в столбик в десятичной системе счисления в точности равно $k$.

Мы складываем числа в столбик в десятичной системе счисления, как обычно делаем это в начальной школе. Например, в следующем сложении происходит два переноса:

Входные данные

Первая строка содержит целое число $T$ ($1 \le T \le 10^5$) — количество тестовых случаев.

Для каждого тестового случая первая строка содержит два целых числа $x, k$ ($1 \le x < 10^{18}, 0 \le k \le 18$).

Выходные данные

Для каждого тестового случая выведите одно целое число, представляющее ответ, в отдельной строке. Если решения не существует, выведите $-1$.

Примеры

Входные данные 1

4
12345678 0
12345678 5
12345678 18
990099 5

Выходные данные 1

1
54322
999999999987654322
9910

$^1$ что означает «进位» на китайском языке.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.