Universal Cup Judging System

Universal Cup

时间限制: 2.5 s 内存限制: 1024 MB 总分: 100
统计

正整数 $n$ が与えられます。各ターンで次の操作を行います:

  1. $n$ の十進表記から数字 $d$ を一様に選びます。
  2. $n\leftarrow n\cdot(d+1)$ として $n$ を更新します。

$n$ が $N$ を超えるまでに必要なターン数の期待値を $998244353$ で割った余りを求めてください。

入力

1 つの入力ファイルには複数のテストケースが含まれます。

入力の最初の行には、テストケースの数を表す整数 $T$ ($1\le T\le 200$) が 1 つ与えられます。

各テストケースの最初の行には、2 つの整数 $n$ と $N$ ($1\le n\le N\le 10^{18}$) が与えられます。

出力

各テストケースについて、答えを表す整数を 1 個、1 行に出力してください。

答えが常に存在することを証明できます。

入出力例

入力 1

3
1 10
1 100
1 1000

出力 1

3
4
942786340

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.