2022 软件学院 ACM 集训队筛选赛

Problem B. Abyss Cycle

The Abyss is alive, it evolves itself and generates new errors every 2000 years, which is called the Abyss Cycle.

There're n possible updates of new errors in an Abyss Cycle, and only one of the updates will win out. To find out the winning update, first the Abyss Cycle would mark all the updates. If at one moment only 1 update is marked, then it win out. Otherwise, the Abyss Cycle would perform the procedure below until one update wins out: all the marked updates would randomly choose an integer at range [1,m] with the same possibilities. Let x denotes the minimal chosen number of all the updates, then all the updates with the chosen number equals to x remain marked, and other updates become unmarked.

Please calculate the expected times to perform the procedure. If it expects to perform \dfrac xy times, you should output the value of \dfrac xy\bmod (10^9+7) , where 10^9+7 is a prime.

输入

Input a single line with two integers n,m(1\le n\le10^3,2\le m\le10^3) .

输出

Output a single line with one integer denotes \dfrac xy\bmod(10^9+7) .

样例

标准输入 复制文本
1 6
标准输出 复制文本
0
标准输入 复制文本
2 2
标准输出 复制文本
2
标准输入 复制文本
3 2
标准输出 复制文本
333333338

提示

In the first example, at the beginning there's only 1 update, so it needn't perform the procedure and the expect times is 0 , and \dfrac01\bmod(10^9+7)=0 .

In the second example, all the possible random-chosen numbers of 2 updates are (1,1),(1,2),(2,1),(2,2) , among which (1,2),(2,1) can find out the one win out, the others cannot and need to perform the procedure again. So that every time, the possibility of perform again is reduce by half, if we calculate the limitation of the geometric sequence, we get: \lim_{n\to\infty}(1+\dfrac12+\dfrac14+\cdots+\dfrac1{2^n})=\lim_{n\to\infty}(2-\dfrac1{2^n})=2 so the expect times is 2 and \dfrac21\bmod(10^9+7)=2 .

In the third example, we can calculate the accurate expect times is \dfrac73 , and \dfrac73\bmod(10^9+7)=333333338 .

登录以提交代码。
单点时限 1 秒
内存限制 128 MB
提交 0
通过 0

A B C D E F G H

鉴于过题情况不理想,比赛时间延长1小时,22:00开始封榜。
可以尝试一下做D,G或H题。
C题是签到题。
请注意题目难度与题目顺序无关。