QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100

#14743. キーが外されたキーボード

Statistics

数字 $0,1,2,\cdots,9$ のキーだけを持つキーボードがあります。

任意の正の整数 $m$ に対して、$m$ の倍数である正の整数を常に入力できることは明らかです。

今、正の整数の数字キーが $k$ 個外されましたが、それでも $m$ の倍数である正の整数を入力したいと思っています。

入力

各入力ファイルには複数のテストケースが含まれます。最初の行には、テストケースの数を表す整数 $T$ ($1\le T\le 5\times 10^4$) が与えられます。

各テストケースについて:

最初の行には 2 個の正の整数 $m,k$ ($1\le m\le 10^7$, $0\le k\le 9$) が与えられます。$k$ 個のキーが外された後に、$m$ の倍数である正の整数を入力する必要があることを表します。

2 行目には、外されたキーを表す $k$ 個の相異なる正の整数 $p_i$ ($1\le p_i\le 9$) が与えられます。

出力

各テストケースについて:

解がある場合は、「数字 $a$ を $b$ 回押す」という操作を複数回行うことで、あなたの操作を出力してください:

最初の行には、必要な操作数を表す整数 $n$ を出力してください。$1\le n\le 100$ を満たす必要があります。

続く $n$ 行には各行に 2 個の整数 $a,b$ を出力してください。$0\le a\le 9$, $1\le b\le 10^{18}$ を満たす必要があり、「数字 $a$ を $b$ 回押す」という 1 回の操作を表します。

解がない場合は、1 行に $-1$ を出力してください。

入出力例

入力 1

2
37 7
2 3 5 6 7 8 9
7 9
1 2 3 4 5 6 7 8 9

出力 1

2
1 3
0 1
-1

注記

入出力例の最初のテストケースでは、出力例の操作で入力される正の整数は $1110$ です。$1110=37\times 30$ は $37$ の倍数です。

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.