#P6395. 千年食谱颂

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

千年食谱颂

Background

Man plans Heaven decides\texttt{Man plans Heaven decides} $$\texttt{Time has flowed since ancient days, and in the blink of an eye}$$Only on the table\texttt{Only on the table} The thousand-year feast never changes\texttt{The thousand-year feast never changes}

  “A-Ling, today is my 1515th 1515-year-old birthday!”
  “Oh... A-Ling can’t go home today.”
  At nine in the morning, Tianyi, still half-asleep, slowly opened her eyes and quietly poked the spot beside her, but only felt the pillow’s faint warmth.
  “It’s my birthday, and you still have to work overtime...” She tossed the phone aside, folded the quilt, walked to the bedside, let her hands hang down, and gently pulled the curtain open. The dazzling sunlight easily scattered the other person’s lingering warmth.
  “So boring!”
  She endured it until night, only to find the fridge already completely empty. How about... taking a look around the food festival?
  Today happened to be the annual food festival in the “Magic City” (Módū, Shanghai). She had thought A-Ling would go with her, and Tianyi had even prepared an extremely detailed plan. But now, with A-Ling not here, the plan fell through as well. Putting on a light casual outfit and bringing her wallet, Tianyi still decided she couldn’t wrong herself when it came to food!
  Just as Tianyi’s hand rested on the doorknob and she gently pulled, the door suddenly flew open, and she was pulled into her lover’s arms...
  Starlight, city lights, food, and... Tianyi’s small tongue lightly licked a blueberry-flavored cone while she secretly glanced at her lover beside her. A slender figure walked with graceful calm; the iconic red “ahoge” on her head flickered like a candle of hope. Under the sea of lights, they slowly flowed within those dark-red eyes... A-Ling turned around, her gaze meeting those emerald-green eyes.
  “Tianyi, Tianyi. What are you thinking about?”
  Seeing her lover shyly turn her face away, with her ears turning red unhelpfully, A-Ling’s mischievous thoughts rose again. She slowly moved closer to her lover’s face and lightly took a sip of her soft pink lips.
  “What are you doing, A-Ling, there are so many people here...” Though she said that, Tianyi still unconsciously leaned toward A-Ling. A-Ling took her lover’s hand. “Come on, I’ll take you to eat through all of this place!”

Problem 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