eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Game, Set and Match

Game, Set and Match

In this problem you need to assist in computing the probability of winning at tennis. Here is a brief explanation of how the scoring system works. In a tennis \textit{match}, players play a certain number of consecutive \textit{sets}. Each \textit{set} is in turn made up of a series of \textit{games} (and may include a \textit{tie-break} if needed). Finally each game is made of \textit{points}. \textbf{Points.} Every point is started by one of the players serving (i.e. hitting the ball into the service box in the opposite court) and the other receiving serve. The server then attempts to return the ball into the server's court and players alternate hitting the ball across the net. When one of the players fails to make a legal return (e.g. if the ball is knocked out of the court), he or she loses the point. The speci cs of how points are won are not important to us. \textbf{Games.} The scoring system within a game is peculiar to say the least. As the player wins points in a game, his score goes from the initial value of \textbf{0} (read "love") to \textbf{15}, \textbf{30}, or \textbf{40} (yes, just when you think you're starting to spot a pattern in this mess it breaks down). There is no a-priori limit to the length of a game (meaning the number of points played), but a player's score is always indicated by one of these numbers according to the following rules. When a player has three points (score \textbf{40}) and wins the following point as well, he wins the game unless the scoreline was \textbf{40-40} (read "deuce") to start with. A player needs to win two consecutive points from deuce to win the game. Winning one gives him advantage; if followed by a second winning point the game is won by him, but if followed by a losing point the score reverts to deuce. Example: at \textbf{40-30}, if the fi rst player wins the next point he wins the game. However, if the second player wins the next three points the game is his. \textbf{Sets.} A player wins a set if he wins at least four games (in the current set) and he is two games ahead of his opponent but, as you may be starting to suspect, there is yet another exception. In case the scoreline for the number of games won reaches six-all (\textbf{6-6}), a tie-break is played instead to decide the set.Example: at 5-4, if the fi rst player wins the next game he takes the set \textbf{6-4}. But if he loses, the set is still undecided and can eventually go to either \textbf{7-5}, \textbf{5-7} or a tie-break. \textbf{Tie-break.} A tie-break (and the set to which it belongs) is won when a player wins at least seven points by a margin of two points or more. \textbf{Match. }The winner of a match is the rst player to win \textbf{2} sets (the wins do not need to be consecutive). Hence a match may go to \textbf{2} or \textbf{3} sets depending on how the game develops. Rafa has been carefully studying his past performances against his next opponent and he knows he wins each point with probability precisely \textbf{p}, irrespective of whether he is serving or receiving and regardless of all other points played. Can you help him assess his chances of winning the match? \InputFile Each test case is described by a single floating point number \textbf{p}, \textbf{0} ≤ \textbf{p} ≤ \textbf{1} in its own line. A value of \textbf{-1} for \textbf{p} marks the end of the input. \OutputFile For each test case, print a single line with the probabilities of Rafa winning a given game, set and match,respectively. These three numbers must be separated by a space character. Your answers should be accurate to within an absolute error of \textbf{10^\{-6\}}.
Лимит времени 1 секунда
Лимит использования памяти 64 MiB
Входные данные #1
0.5
0.3
0.7
-1
Выходные данные #1
0.50000000000 0.50000000000 0.50000000000
0.09921103448 0.00016770463 0.00000008437
0.90078896552 0.99983229537 0.99999991563