Universal Cup Judging System

Universal Cup

Límite de tiempo: 3 s Límite de memoria: 1024 MB Puntuación total: 100 Dificultad: [mostrar]
Estadísticas

Cho một số nguyên dương $x$, hãy tìm số nguyên dương $y$ nhỏ nhất sao cho số lần nhớ$^1$ của phép cộng $x+y$ đúng bằng $k$.

Chúng ta thực hiện phép cộng theo cột trong hệ thập phân, giống như cách chúng ta thường làm ở trường tiểu học. Ví dụ, có hai lần nhớ trong phép cộng dưới đây:

Dữ liệu vào

Dòng đầu tiên chứa một số nguyên $T$ ($1 \le T \le 10^5$) – số lượng bộ dữ liệu kiểm tra.

Với mỗi bộ dữ liệu, dòng đầu tiên chứa hai số nguyên $x, k$ ($1 \le x < 10^{18}, 0 \le k \le 18$).

Dữ liệu ra

Với mỗi bộ dữ liệu, in ra một số nguyên duy nhất là đáp án trên một dòng. Nếu không có lời giải, hãy in ra $-1$.

Ví dụ

Dữ liệu vào 1

4
12345678 0
12345678 5
12345678 18
990099 5

Dữ liệu ra 1

1
54322
999999999987654322
9910

¹ có nghĩa là “进位” trong tiếng Trung

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.