#P6395. 千年食谱颂

    ID: 4967 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>动态规划,dp数学2020组合数学期望

千年食谱颂

Description

There are a total of nn stalls at the food festival. Initially (at time 00), Tianyi has not tasted any of them. Tianyi’s flag is to taste them all. Therefore, starting from time 11, at each moment, Tianyi will choose one of the nn stalls uniformly at random to taste. However, due to the large number of customers, many stalls will run short of ingredients and have to leave midway. When a stall leaves, a new stall (one that has never appeared before) immediately enters, and we call this a leaving event. A-Ling knows that all leaving events happen between two adjacent moments, and for each stall, the probability of leaving between any two moments is pp.

Tianyi leaned her fluffy head closer and asked A-Ling, “In expectation, at which moment will I have tasted all nn stalls currently present?”

Input Format

One line with three integers n,a,bn,a,b, meaning there are nn stalls, and the leaving probability is p=abp=\dfrac{a}{b}.

Output Format

One line with one integer, meaning your answer.

Since the answer may be a decimal, to avoid loss of precision, output the value of the answer modulo 998244353998244353.

2 1 2
5

Hint

Constraints

For different test points, we use the following data sizes and properties:

Test Point ID nn \leq Special Property 1 Special Property 2
121 \sim 2 500500 \sqrt{} ×\times
383 \sim 8 ×\times
9119 \sim 11 30003000 \sqrt{}
122512 \sim 25 ×\times

Special Property 1: a=0a=0.

Special Property 2: a=1,b=2a=1,b=2.

For 100%100\% of the data, 1n3000,0a<b<9982443531 \le n \le 3000,0 \le a<b<998244353.


Background (Continued)

  A-Ling watched Tianyi, who did not care about her eating manners at all, feeling both annoyed and amused. But seeing the money on the black card in her bag lose one 00 after another, her expression grew darker and darker...
  “Hey, two-tone hair, send another card over!” A-Ling had no choice but to vent her anger at her brother, hung up, and then put on a gentle smile again.
  “A-Ling, A-Ling, you should taste some too.” Tianyi finally remembered that A-Ling had barely eaten anything.
  “No rush. Tonight when we get home, there’s still a big meal waiting for me.” A-Ling smiled at Tianyi, smiling with a wicked charm.
  “Uh, so what is the big meal?” Tianyi couldn’t figure it out, but still felt a little uneasy.
        “You’re the same as always, Tianyi.”

Translated by ChatGPT 5