Tri-du
Time limit1sMemory limit512 MB
Given two known card values, pick a third value from 1 to 13 that maximizes the chance of holding a winning triple or pair against one opponent.
- Level
Medium5 of 10
- Topics
- Math, Probability, Brute force
- Solved
- No attempts yet
Problem
Tri-du is a card game derived from Truco. It uses one standard deck of 52 cards with thirteen cards in each suit, but suits have no effect on the result. Only the card values matter, and every value is an integer from to .
In one round each player receives three cards. The rules are short.
- A triple (three cards of the same value) beats a pair (two cards of the same value).
- Between two triples, the one made of the higher value wins.
- Between two pairs, the one made of the higher value wins.
Many rounds end with no winner. In that case the dealt cards go back into the deck, the deck is shuffled, and a new round starts.
One player has already received two of the three cards and knows their values. Write a program that finds the value of the third card that maximizes this player's probability of winning the round.
Input
The first line contains two integers and , separated by one space, the values of the two cards already received. (, )
Output
Print one line with a single integer, the value of the third card that maximizes the probability of winning.