QOJ.ac

QOJ

時間限制: 3 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓

#18696. 長度字串

统计

「長度字串」(Length String)是指僅由數字 $0-9$ 與連字號(-)組成的字串,且必須滿足以下條件:

  • 不會出現連續兩個以上的 -
  • 字串的第一個字元不是 0
  • 字串的最後一個字元不是 -
  • - 後面的字元不會是 0
  • 將字串中僅由數字組成的最長後綴解釋為十進位數時,其值等於該字串的長度。若此類後綴為空字串,則視為 $0$。
  • 若字串中出現 -,則從字串開頭到最後一個 - 之前的部分字串也是一個長度字串。

對於任意非負整數 $n$,長度為 $n$ 的長度字串有且僅有一個。以下分別為長度 $5, 8, 13$ 的長度字串範例:

$1-3-5$ $-2-4-6-8$ $1-3-5-7-10-13$

給定自然數 $a$ 與非負整數 $b$,試找出長度為 $a \times 10^b$ 的長度字串。

輸入格式

第一行給出測試案例的數量 $T$。($1 \le T \le 100\,000$) 每個測試案例包含兩個由空格分隔的整數 $a$ 與 $b$。($1 \le a \le 10^9, 0 \le b \le 10^6$)

輸出格式

對於每個測試案例,輸出長度為 $a \times 10^b$ 的長度字串。若 $a \times 10^b \ge 21$,則僅輸出該字串的前 $17$ 個字元,並依照範例格式輸出。

範例

輸入格式 1

3
5 0
8 0
13 0

輸出格式 1

1-3-5
-2-4-6-8
1-3-5-7-10-13

輸入格式 2

2
25 4
32 6

輸出格式 2

1-3-5-7-10-13-16-...
-2-4-6-8-11-14-17...

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.