Universal Cup Judging System

Universal Cup

Time Limit: 3 s Memory Limit: 1024 MB Total points: 100 Difficulty: [show]
Statistics

양의 정수 $x$가 주어졌을 때, $x + y$의 올림(carry)$^1$ 횟수가 정확히 $k$번이 되는 최소의 양의 정수 $y$를 구하시오.

우리는 초등학교에서 배우는 방식과 같이 십진법의 세로셈으로 숫자를 더한다. 예를 들어, 다음 덧셈에는 두 번의 올림이 발생한다.

입력

첫 번째 줄에는 테스트 케이스의 수 $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.