Public Judge

pjudge

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

#21618. 【ExPR #1】乘积

Statistics

给定两个正整数 $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}$

Discussions

About Discussions

The discussion section is only for posting: Editorials, 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. Submitting multiple issues may cause your account to be banned.
  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.