Universal Cup Judging System

Universal Cup

実行時間制限: 3 s メモリ制限: 1024 MB 満点: 100 難易度: [表示]
統計

給定一個正整數 $x$,請找出最小的正整數 $y$,使得 $x+y$ 的進位(carries)次數恰好為 $k$。

我們使用十進位的直式加法來進行數字相加,就像我們在小學時所學的一樣。例如,在下方的加法中,總共有兩次進位。

輸入格式

第一行包含一個整數 $T$ ($1 \le T \le 10^5$),代表測試資料的組數。

對於每一組測試資料,第一行包含兩個整數 $x, k$ ($1 \le x < 10^{18}, 0 \le k \le 18$)。

輸出格式

對於每一組測試資料,輸出一個整數代表答案。如果沒有解,則輸出 $-1$。

範例

輸入格式 1

12345678 0

輸出格式 1

1

輸入格式 2

12345678 5

輸出格式 2

54322

輸入格式 3

12345678 18

輸出格式 3

999999999987654322

輸入格式 4

990099 5

輸出格式 4

9910

$^1$ which means “进位” in Chinese

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.