Roulette
Time limit1sMemory limit1024 MB
Albums cost A_i won for B_i tickets each, and each re-spin costs R won; find the minimum expected cost to guarantee a win as a reduced fraction.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Probability, Math
- Solved
- No attempts yet
Problem
You are a big fan of Korea's biggest rockstar, Koosaga. Koosaga has announced a lottery event offering fans a once-in-a-lifetime chance at a one-on-one meeting.
Koosaga sells kinds of albums. When you buy the -th album, it costs won and gives you lottery tickets. You can buy multiple copies of the same album.
On the day of the draw, a large roulette wheel with cells containing participant names decides the winner. Every cell has an equal chance of being selected. The number of cells with your name equals the number of lottery tickets you hold.
Koosaga spins the wheel once to pick the winner. By paying won, you can ask Koosaga to spin the wheel again. You can pay for as many re-spins as you want.
The total number of cells belonging to other participants is . None of them requests a re-spin. Only you request re-spins, when you want to.
Find the strategy that guarantees your win with the minimum expected cost.
Input
The first line contains three space-separated integers , , .
The next lines each contain two space-separated integers. The -th line contains and .
Output
Print a single line containing two space-separated positive integers , . must be the minimum expected cost to win, and and must be coprime. It can be proven that the minimum expected cost can be written in this form.
Constraints
- ()
- ()