Lazy Student
Time limit1sMemory limit256 MB
Given k exam days, find the minimum expected fraction of topics Raccoon must learn, where each attempt passes with probability equal to the fraction learned, modulo 1000000007.
- Level
Hard8 of 10
- Topics
- Probability, Math, Dynamic programming
- Solved
- No attempts yet
Problem
The Algorithms course exam is coming soon, and there are days when you can attempt it. You can come on any subset of the days until you finally pass. Raccoon, a young lazy student, definitely wants to pass, but he also wants to learn as few topics as possible. If only one exam day is left, he has to learn all the topics. If there are 10 attempts, he may hope that learning a third of the topics is enough.
Here is the process in detail. All topics form the segment . Raccoon learns the first topics, where is a real number from to . When he comes to an exam day, he passes with probability . He may learn more topics before the exams or between attempts, and he never forgets what he has learned. For example, he may learn before the first exam day and then after a failure, reaching a total of . If he fails on every day before the last one, he learns all the topics before the last attempt, because he definitely wants to pass.
Raccoon does not want to learn much. He chooses the strategy that gives the smallest expected amount of topics he has to learn. What is this expected amount?
Input
A single integer is given: the number of attempts to pass the exam ().
Output
The answer can be written as an irreducible fraction . Print and separated by a space, where .
Hint
For the first input (when there are just exam days), Raccoon may learn of all topics before the first attempt, and another if he fails on the first day. The expected amount of topics to be learned is therefore .