QOJ.ac

QOJ

実行時間制限: 3 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓

#18696. 길이 문자열

統計

「長さ文字列(length string)」とは、数字の $0$ から $9$ およびハイフン(-)のみで構成される文字列のうち、以下の条件を満たすものを指す。

  • - が $2$ つ以上連続して出現しない。
  • 文字列の最初の文字は 0 ではない。
  • 文字列の最後の文字は - ではない。
  • - の直後の文字として 0 は出現しない。
  • 文字列に含まれる数字のみで構成された接尾辞のうち、最も長いものを $10$ 進数の数値として解釈すると、その値は文字列全体の長さと等しい。ただし、そのような接尾辞が空文字列である場合は $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$ である長さ文字列を求めよ。

長さが 13 である長さ文字列の例

入力

最初の行にテストケースの数 $T$ が与えられる。($1 \le T \le 100\,000$)

各テストケースは、2つの整数 $a, b$ が空白区切りで1行に与えられる。($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.