Mercurialist
시간 제한2초메모리 제한1024 MB
엘릭서, 수은, 요구르트 병을 매일 무작위로 마실 때 수은의 기한을 고려해 앨리스가 영원히 살 확률을 구한다.
문제
This country has a medicine for immortality. Alice got bottles from the Hatter.
bottles contain elixir. If Alice drinks it, she will immediately become immortal.
bottles contain mercury, and each has a different toxicity. If she drinks the -th bottle, the following event will occur after days.
- Event : Alice will immediately die if she has not drunk the elixir before event . If she has drunk the elixir, she won't die.
The remaining bottles contain yogurt. Nothing will happen when Alice drinks it.
At the same time every morning, Alice chooses one non-empty bottle with equal probability and drinks it. If all bottles are empty, she does nothing.
Answer the probability that Alice will be alive days after the first day she starts drinking bottles. Note that Alice won't die other than events.
The probability can be expressed as using coprime integers and . Output a non-negative integer less than such that . It can be proven that the probability is a rational number, and is uniquely determined under the conditions of this problem.
입력
출력
Output defined in the statement. Add a new line at the end of the output.
제한
- All inputs consist of integers.
힌트
In Sample Input 1, Alice will only die if she drinks mercury on day 1 and yogurt on day 2. The probability of death is , therefore the answer is .
In Sample Input 2, Alice never dies.