아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Odds of Mia

시간 제한1초메모리 제한1024 MB

요약
미아 게임에서 두 플레이어의 주사위가 일부만 알려졌을 때 플레이어 1이 이길 확률을 기약분수로 구한다.
난이도

보통10점 중 5점

유형
확률, 조합론, 구현, 완전 탐색
정답자
아직 제출이 없습니다

문제

This problem relates to the game of Mia introduced earlier. We recommend that you first solve Mia to understand how the game is scored. In this problem, you are asked to compute the odds that player 1 will win given partial knowledge of both rolls.

입력

The input will contain multiple test cases. Each test case contains on a single line four symbols s0 s1 r0 r1 where s0 s1 represent the dice rolled by players 1 and r0 r1 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.

출력

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).

힌트

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 * 1/6 + 1/6 * 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.

예제1

  1. 예제 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