#P6395. 千年食谱颂
千年食谱颂
Background
$$\texttt{Time has flowed since ancient days, and in the blink of an eye}$$ “A-Ling, today is my th -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 stalls at the food festival. Initially (at time ), Tianyi has not tasted any of them. Tianyi’s flag is to taste them all. Therefore, starting from time , at each moment, Tianyi will choose one of the 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 .
Tianyi leaned her fluffy head closer and asked A-Ling, “In expectation, at which moment will I have tasted all stalls currently present?”
Input Format
One line with three integers , meaning there are stalls, and the leaving probability is .
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 .
2 1 2
5
Hint
Constraints
For different test points, we use the following data sizes and properties:
| Test Point ID | Special Property 1 | Special Property 2 | |
|---|---|---|---|
Special Property 1: .
Special Property 2: .
For of the data, .
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 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