Public Judge

pjudge

时间限制: 2 s 内存限制: 512 MB 总分: 100 可 Hack ✓

#21618. 【ExPR #1】Product

统计

Given two positive integers $n$ and $m$.

You have a positive integer $M$, initially $M=1$. You will perform several operations. In each operation, you choose an integer $x$ uniformly at random from $[1, n]$ and update $M := M \times x$. The process stops when $M > m$.

Calculate the expected number of operations.

It can be proven that the answer is always a rational number. Let it be $\frac{a}{b}$ (where $a$ and $b$ are coprime positive integers, and it is guaranteed that $b$ is not a multiple of $998244353$). You need to output an integer $x$ such that $0 \le x < 998244353$ and $a \equiv bx \pmod{998244353}$. It can be proven that such an $x$ exists and is unique.

Input

A single line containing two positive integers $n$ and $m$.

Output

A single line containing an integer $x$, as defined in the problem description.

Examples

Input 1

3 2

Output 1

748683267

Note 1

The answer is $\frac{9}{4}$, and $4 \times 748683267 \equiv 9 \pmod{998244353}$.

Input 2

2 39

Output 2

12

Input 3

316 12048

Output 3

638683159

Constraints

This problem consists of 10 test cases, each worth 10 points.

For all test cases, $2 \le n \le 9 \times 10^8$ and $1 \le m \le 10^9$.

Test Case ID $n \le$ $m \le$
$1 \sim 3$ $5000$ $5000$
$4 \sim 5$ $10^6$ $10^6$
$6 \sim 8$ $300$
$9 \sim 10$

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.