QOJ.ac

QOJ

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

#18696. 长度字符串

统计

“长度字符串”是指仅由数字 $0-9$ 和连字符(‘-’)组成的字符串,且满足以下条件:

  • ‘-’ 不会连续出现两次或以上。
  • 字符串的第一个字符不是 ‘0’。
  • 字符串的最后一个字符不是 ‘-’。
  • ‘-’ 后的字符不能是 ‘0’。
  • 将字符串中仅由数字组成的后缀中最长的一个解析为十进制数,其值等于该字符串的长度。若这样的后缀为空字符串,则解析为 $0$。
  • 如果字符串中出现 ‘-’,则从字符串开头到最后一个 ‘-’ 之前的部分也是一个“长度字符串”。

对于任意非负整数 $n$,长度为 $n$ 的“长度字符串”唯一存在。以下分别是长度为 $5, 8, 13$ 的“长度字符串”示例:

1-3-5-7-10-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.