Sat Down
InterviewTime limit1sMemory limit256 MB
Given your two cards, count how many of the 18 choose 2 possible opponent hands you beat, and print the win probability to three decimals.
- Level
Easy3 of 10
- Topics
- Brute force, Implementation, Math, Combinatorics
- Solved
- No attempts yet
Problem
Seotda, which means "stood up", is a Korean card game played by two or more people with 20 hwatu cards. Anjatda, which means "sat down", is a simplified version of it.
Anjatda uses cards numbered 1 to 10, two copies of every number, 20 cards in total. Exactly two people play.
The game runs like this.
- The two players take turns, and each of them takes 2 random cards out of the 20.
- A player cannot take a card the other player already took. You know which cards you took, but you do not know which cards the other player took.
- Both players reveal their hands.
- The player with the stronger hand rank wins. If the two players have the same rank, the game is a draw.
The ranks are listed strongest first.
- 10-ttaeng: both cards are 10
- 9-ttaeng: both cards are 9
- ...
- 2-ttaeng: both cards are 2
- 1-ttaeng: both cards are 1
- 9-kkeut: not a ttaeng, and the sum of the two cards leaves remainder 9 when divided by 10
- 8-kkeut: not a ttaeng, and the sum of the two cards leaves remainder 8 when divided by 10
- ...
- 1-kkeut: not a ttaeng, and the sum of the two cards leaves remainder 1 when divided by 10
- 0-kkeut: not a ttaeng, and the sum of the two cards leaves remainder 0 when divided by 10
For example, suppose Younghak holds 1 and 1 while his opponent holds 10 and 9. Younghak has 1-ttaeng and the opponent has 9-kkeut, so Younghak has the stronger rank and wins.
Younghak is shrewd and bets money only when his chance of winning is high. He has seen his own hand and knows nothing about his opponent's hand. The opponent takes 2 of the remaining 18 cards, and every choice of 2 cards is equally likely.
Given Younghak's hand, find the probability that Younghak wins. A draw does not count as a win.
Input
The first line contains two integers and , the two cards in Younghak's hand. ()
Output
Print the probability that Younghak wins, rounded to three digits after the decimal point.
Trailing zeros must be printed. For example, 0.700 is correct and 0.7 is wrong.