#P6395. 千年食谱颂
千年食谱颂
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
京公网安备 11011102002149号