6 Maratona NexTI - 2018

#### Start

2018-05-18 17:00 UTC

## 6 Maratona NexTI - 2018

#### End

2018-05-21 17:00 UTC
The end is near!
Contest is over.
Not yet started.
Contest is starting in -491 days 21:06:36

72:00:00

0:00:00

# Problem COdds of Mia

Mia is a dice game for two players. Each roll consist of two dice. Mia involves bluffing about what a player has rolled, but in this problem we focus only on its scoring rules. Unlike most other dice games, the score of a roll is not simply the sum of the dice.

Instead, a roll is scored as follows:

• Mia ($12$ or $21$) is always highest.

• Next come doubles ($11$, $22$, and so on). Ties are broken by value, with $66$ being highest.

• All remaining rolls are sorted such that the highest number comes first, which results in a two-digit number. The value of the roll is the value of that number, e.g. $3$ and $4$ becomes $43$.

Player $1$ and $2$ each roll two dice. You are asked to compute the odds that player 1 will win given partial knowledge of both rolls.

## Input

The input will contain multiple, different test cases. Each test case contains on a single line four symbols $s_0 \ s_1 \ r_0 \ r_1$ where $s_0 \ s_1$ represent the dice rolled by player $1$ and $r_0 \ r_1$ represents the dice rolled by player $2$. A ‘*’ represents that the value is not known, otherwise a digit represents the value of the dice. The input will be terminated by a line containing $4$ zeros.

## Output

For each test case output the odds that player $1$ will win. If the odds are $0$ or $1$, output $0$ or $1$. Otherwise, output the odds in the form $a/b$ where $a$ and $b$ represent the nominator and denominator of a reduced fraction (i.e., in lowest terms).

## Sample Output Explanation

For * * 1 2, the best player $1$ can do is tie, so his chance of winning is $0$. For 1 2 * *, player $1$ wins unless player $2$ rolls a Mia, which happens $1$ out of $18$ times. For 1 2 1 3, 3 1 2 1, and 6 6 6 6 the result is already known. For * 2 2 2, player $1$ wins only if she rolls a $1$. For * 2 * 6, player $1$ wins if he rolls a $1$. If he rolls a $2$, he wins with probability $5/6$. He loses if he rolls a $3$, $4$, or $5$. If he rolls a $6$ he wins only if player $2$ rolls a $1$. Thus, his chance of winning is $1/6 + 5/6 \cdot 1/6 + 1/6 \cdot 1/6 = 12/36 = 1/3$. When no dice are known, Player $1$ will win in $615$ of all possible $1\, 296$ outcomes. Player $2$ will lose in $615$ cases, and there are $66$ possible ties. Thus, her chance of winning is $615/1296 = 205/432$.

Sample Input 1 Sample Output 1
* * 1 2
1 2 * *
1 2 1 3
3 1 2 1
6 6 6 6
* 2 2 2
* 2 * 6
* * * *
0 0 0 0

0
17/18
1
0
0
1/6
1/3
205/432