Public Judge

pjudge

Time Limit: 2 s Memory Limit: 512 MB Total points: 100 Hackable ✓
統計

给定两个正整数 $n,m$ 。

你有一个正整数 $M$ ,初始 $M=1$ 。你将进行若干次操作,每次在 $[1,n]$ 中均匀随机选取一个整数 $x$ ,并令 $M:=M\times x$ 。当 $M>m$ 时停止操作。

求期望进行多少次操作。

可以证明,答案一定为有理数。设其为 $\frac ab$($a$ 和 $b$ 为互质的正整数,数据保证 $b$ 不为 $998244353$ 的倍数),则你需要输出一个整数 $x$ 满足 $0\le x < 998244353$ 且 $a\equiv bx \pmod{998244353}$ 。可以证明这样的 $x$ 唯一存在。

输入格式

一行,两个正整数 $n,m$ 。

输出格式

一行,一个整数 $x$ ,意义同题目描述。

样例一

input

3 2

output

748683267

explanation

答案为 $\frac 94$,$4 \times 748683267=9 \pmod {998244353}$ 。

样例二

input

2 39

output

12

样例三

input

316 12048

output

638683159

数据范围与提示

本题共 $10$ 组测试点,各 $10$ 分。

对于所有数据,$2\le n\le 9\times 10^8,1\le m\le 10^9$ 。

测试点编号 $n\le $ $m\le $
$1\sim 3$ $5000$ $5000$
$4\sim 5$ $10^6$ $10^6$
$6\sim 8$ $300$ $ $
$9\sim 10$ $ $ $ $

时间限制:$\texttt{2s}$

空间限制:$\texttt{512MB}$

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.