# Unlikely events

0.72 Xavier Martínez (also known as Greivax, *el colló dret de la
foscor*, and Xavi P.) is one of the biggest nerds of the history of the
UPC programming teams. Recently, Xavi has married, which can be
considered a rather unlikely event. But this is not the first time that
something unexpected happens to Xavi. For instance, he qualified for his
first ICPC Final when his team solved a problem at the very last second,
somehow managed to survive the travel to China (see picture to the
right), qualified for a second ICPC Final solving almost nothing at the
corresponding regional contest, later was hired by one of the world top
companies (which against all odds has not collapsed yet), etc.

0.26

::: center
![image](xavi.eps){width="4.0cm"}
:::

Let's solve a problem inspired by this sequence of unlikely events:
Given the independent probability of each event to happen, choose any
subset of elements so that the probability of all them happening is as
small as possible. To make the problem interesting, you are not allowed
to choose any adjacent events.

## Input

Input consists of several cases, each with the number of events $n$,
followed by $n$ simplified fractions $n_i/d_i$. Assume
$1 \le n \le 200$, $2 \le d_i \le 6$, and $1 \le n_i < d_i$.

## Output

For each case, print the minimum probability of a subset of non-adjacent
events, as a fraction with no common factors.

## Problem information

Author: Salvador Roura

Generation: 2026-01-25T12:09:28.225Z

© *Jutge.org*, 2006--2026.\
<https://jutge.org>
