QOJ.ac

QOJ

حد الوقت: 4 s حد الذاكرة: 1024 MB مجموع النقاط: 100 قابلة للهجوم ✓

#18391. クオンの好奇心

الإحصائيات

クオンはある日突然、こんな疑問を抱いた。「演算結果が $N$ になる数式はいくつあるのだろうか?」

クオンは、演算結果が $N$ になる数式の後ろに +0-0 などを付け加えても演算結果は $N$ のままであるため、この操作を繰り返せば演算結果が $N$ になる数式を無限に作れてしまうという悲しい事実に気づいてしまった。

そこでクオンは、数式の長さが $M$ でなければならないという制約を追加したが、今度は答えを出すことができなかった。皆さんが代わりにこの問題を解いてあげよう!

数式は次のように定義される。

  • 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 のみで構成されており、0 で始まらない長さ $1$ 以上の文字列である。ただし 00 で始まるが、例外的にである。
  • 数式は $1$ つ以上のを含み、各+ または - で区切られている文字列である。

言い換えると、数式は次の正規表現を満たす文字列を指す。

  • (([1-9][0-9]*|'0')[+-]))*([1-9][0-9]*|'0')

入力

1 行目に $N$ と $M$ が空白区切りで与えられる。 ($0 \le N \le 10^5, 1 \le M \le 11$)

出力

長さ $M$ で演算結果が $N$ になる異なる数式の数を求めよ。ただし、そのような数式は非常に多くなる可能性があるため、$10^9+7$ で割った余りを出力せよ。

入出力例

入力 1

5 3

出力 1

11

入力 2

123 3

出力 2

1

入力 3

100000 5

出力 3

0

入力 4

0 2

出力 4

0

入力 5

10 3

出力 5

9

注記

例 1: 長さ $3$ で演算結果が $5$ になる数式は 0+5, 1+4, 2+3, 3+2, 4+1, 5+0, 5-0, 6-1, 7-2, 8-3, 9-4 の $11$ 個である。

例 2: 数式は +- を含まない場合もある。

例 5: 数式は +- で始めることはできない。

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.