Back To School '17: Avalon

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 256M

Problem type

vev is addicted to the game Avalon. She is currently playing a game and wants to make an informed decision on who to put on her quest. There are G distinct groups of players, each with p_g players. Of the p_g players in the group, e_g of them are considered to be evil (e_g \le p_g). Assuming vev chooses a single player randomly from each group, what is the probability that she selects zero evil players?

Input Specification

The first line contains an integer G, representing the number of distinct groups of players.

The next G lines each contain two space separated integers e_g and p_g, the number of evil players in the group, and the total players in the group respectively.


1 \le G \le 1000

0 \le e_g \le p_g

1 \le p_g \le 10^9

Output Specification

Print the probability that she chooses zero evil players. Your answer will be considered correct if it is within 10^{-6} of the judge's answer.

Sample Input 1

2 4
1 2

Sample Output 1


Sample Input 2

0 10
10 10

Sample Output 2



There are no comments at the moment.