 Seven and a half 

‘Warning, this problem is not easy! ‘Do you know to play to seven and a
half? In this game of chance your aim is to win to the dealer. First,
you play a hand of seven and a half, and then plays the dealer: the hand
with the highest total wins as long as it doesn’t exceed. ‘During the
years, huge fortunes have changed of hands because of this game! (Well,
the previously sentence is probably false, but it does its function).

We will play the following simplified version of seven an a half. First,
is the turn of the player: he will ask for cards until he decides to
stand. The cards in game are the numbers from 1 to 7 (their value is the
number), and the 3 face cards (their value is a half). The score of the
player is the sum of the points of the cards in the moment he stands,
with the only restriction that he cannot exceed 7.5 points; if so, he
would obtain the score −1. Then, the dealer plays, with the aim of
improve the score obtained by the player. The game ends when the dealers
stands, busts or there is not more cards. Wins the game the one (player
or dealer) that obtains the maximal score. In a event of a tie, the
player wins.

In this problem you will have to help a player to beat the dealer,
computing the probability that he has to win if he has ask for another
card, and the probability that he has if he decides to stand. We assure
you that the player as well as the dealer play perfectly (the player
always takes the decision that has the greatest probability of success,
and the dealer stops asking for cards as soon as his score is greater
than the score of the player).

Input

A number n < 20 in a line, that describes the number of cases. Then, n
lines, each one of them describing a case: a character C followed by
exactly 8 numbers, separated by spaces. The character c describes the
first card that the player has received, and it is the letter ’F’ (to
indicate that he has received a face card) or one of the numbers from
’1’ to ’7’, to indicate that he has received a number. The other 8
numbers are the number of cards of each type that remains in the deck
after being given this first card: the first of the 8 numbers contains
the number of face cards, and the other seven the number of cards of
score from 1 to 7.

Your program must solve all the cases in 1 second of time.

Output

Your program must print, for each case, two percentages in a line,
separated by spaces. The first percentage is the probability that, given
the deck and the initial card, has the player to win if he asks for
other card; the second percentage is the probability that he will have
to win if he stands. It must print the precentages without decimals,
rounding to the nearest integer –the input will be such that any
probability will have the decimal places between 0.499999 and 0.500001,
to avoid rounding errors.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T12:14:52.781Z

© Jutge.org, 2006–2026.
https://jutge.org
