Knowee
Questions
Features
Study Tools

The King wants to marry off his daughter, and he wants her husband to have the greatest innate luckiness possible. To find such a person he decided to hold a heads-or-tails tournament.If person A๐ด with luckiness x๐‘ฅ and person B๐ต with luckiness y๐‘ฆ play heads-or-tails against each other, person A๐ด wins with probability x/(x+y)๐‘ฅ/(๐‘ฅ+๐‘ฆ).The tournament has several rounds. Each round some participants are split into pairs. Each pair plays against each other, and the loser leaves the tournament.The participants are numbered from 11 to n๐‘›. During the first round, a number k๐‘˜ (1โ‰คkโ‰คn1โ‰ค๐‘˜โ‰ค๐‘›) is selected such that nโˆ’k/2๐‘›โˆ’๐‘˜/2 is a power of 22 (such k๐‘˜ always exists and is unique). Only participants numbered from 11 to k๐‘˜ take part in the first round. It ensures that in all other rounds the number of participants is the power of 22.During other rounds, all the participants who still have not left the tournament take part. If during some round, participants numbered p1<โ€ฆ<p2m๐‘1<โ€ฆ<๐‘2๐‘š take part, then they are split into pairs in the following manner: participant p2iโˆ’1๐‘2๐‘–โˆ’1 plays against participant p2i๐‘2๐‘– for each i๐‘– from 11 to m๐‘š.The rounds are held until only one participant is left. He is declared the winner of the tournament and he will marry the King's daughter. The princess can't wait to find out who is her future husband. She asked every participant to tell her his luckiness. Assuming they did not lie, she wants to know the probability of each participant winning the tournament. As you are the best friend of the princess, she asks you to help her.InputThe first line of the input contains the number of participants, n๐‘› (2โ‰คnโ‰ค3โ‹…1052โ‰ค๐‘›โ‰ค3โ‹…105). The second line of the input contains n๐‘› integer numbers, a1,โ€ฆ,an๐‘Ž1,โ€ฆ,๐‘Ž๐‘› (1โ‰คaiโ‰ค1091โ‰ค๐‘Ž๐‘–โ‰ค109). The luckiness of the i๐‘–-th participant equals to ai๐‘Ž๐‘–.OutputPrint n๐‘› numbers pi๐‘๐‘–. The i๐‘–-th number should be the probability of the i๐‘–-th participant winning the tournament. The absolute error of your answer must not exceed 10โˆ’910โˆ’9.ExampleinputCopy51 4 1 1 4outputCopy0.026 0.3584 0.0676 0.0616 0.4864NoteHere is an example of a tournament bracket, showing the winning probability in each pair.

Question

The King wants to marry off his daughter, and he wants her husband to have the greatest innate luckiness possible. To find such a person he decided to hold a heads-or-tails tournament.If person A๐ด with luckiness x๐‘ฅ and person B๐ต with luckiness y๐‘ฆ play heads-or-tails against each other, person A๐ด wins with probability x/(x+y)๐‘ฅ/(๐‘ฅ+๐‘ฆ).The tournament has several rounds. Each round some participants are split into pairs. Each pair plays against each other, and the loser leaves the tournament.The participants are numbered from 11 to n๐‘›. During the first round, a number k๐‘˜ (1โ‰คkโ‰คn1โ‰ค๐‘˜โ‰ค๐‘›) is selected such that nโˆ’k/2๐‘›โˆ’๐‘˜/2 is a power of 22 (such k๐‘˜ always exists and is unique). Only participants numbered from 11 to k๐‘˜ take part in the first round. It ensures that in all other rounds the number of participants is the power of 22.During other rounds, all the participants who still have not left the tournament take part. If during some round, participants numbered p1<โ€ฆ<p2m๐‘1<โ€ฆ<๐‘2๐‘š take part, then they are split into pairs in the following manner: participant p2iโˆ’1๐‘2๐‘–โˆ’1 plays against participant p2i๐‘2๐‘– for each i๐‘– from 11 to m๐‘š.The rounds are held until only one participant is left. He is declared the winner of the tournament and he will marry the King's daughter. The princess can't wait to find out who is her future husband. She asked every participant to tell her his luckiness. Assuming they did not lie, she wants to know the probability of each participant winning the tournament. As you are the best friend of the princess, she asks you to help her.InputThe first line of the input contains the number of participants, n๐‘› (2โ‰คnโ‰ค3โ‹…1052โ‰ค๐‘›โ‰ค3โ‹…105). The second line of the input contains n๐‘› integer numbers, a1,โ€ฆ,an๐‘Ž1,โ€ฆ,๐‘Ž๐‘› (1โ‰คaiโ‰ค1091โ‰ค๐‘Ž๐‘–โ‰ค109). The luckiness of the i๐‘–-th participant equals to ai๐‘Ž๐‘–.OutputPrint n๐‘› numbers pi๐‘๐‘–. The i๐‘–-th number should be the probability of the i๐‘–-th participant winning the tournament. The absolute error of your answer must not exceed 10โˆ’910โˆ’9.ExampleinputCopy51 4 1 1 4outputCopy0.026 0.3584 0.0676 0.0616 0.4864NoteHere is an example of a tournament bracket, showing the winning probability in each pair.

...expand
๐Ÿง Not the exact question you are looking for?Go ask a question

Solution

This problem is about a tournament where the winner is determined by their "luckiness" factor. The King wants to marry off his daughter to the participant with the highest luckiness. The luckiness of a participant is

Similar Questions

Three friends gathered to play a few games of chess together.In every game, two of them play against each other. The winner gets 22 points while the loser gets 00, and in case of a draw, both players get 11 point each. Note that the same pair of players could have played any non-negative number of times (possibly zero). It is also possible that no games were played at all.You've been told that their scores after all the games were played were p1๐‘1, p2๐‘2 and p3๐‘3. Additionally, it is guaranteed that p1โ‰คp2โ‰คp3๐‘1โ‰ค๐‘2โ‰ค๐‘3 holds.Find the maximum number of draws that could have happened and print it. If there isn't any way to obtain p1๐‘1, p2๐‘2 and p3๐‘3 as a result of a non-negative number of games between the three players, print โˆ’1โˆ’1 instead.InputEach test contains multiple test cases. The first line contains the number of test cases t๐‘ก (1โ‰คtโ‰ค5001โ‰ค๐‘กโ‰ค500). The description of the test cases follows.The first line of each test case contains three integers p1๐‘1, p2๐‘2 and p3๐‘3 (0โ‰คp1โ‰คp2โ‰คp3โ‰ค300โ‰ค๐‘1โ‰ค๐‘2โ‰ค๐‘3โ‰ค30) โ€” the scores of the three players, sorted non-decreasingly.OutputFor each testcase, print one number โ€” the maximum possible number of draws that could've happened, or โˆ’1โˆ’1 if the scores aren't consistent with any valid set of games and results.ExampleinputCopy70 0 00 1 11 1 11 1 23 3 33 4 51 1 10outputCopy01-12-162NoteIn the first example, no games were played at all, so no draws could occur either.For the second example, exactly one game occurred between the second and the third player and it ended in draw, so the answer is 11.It's easy to see that there's no set of games achieving the scores in third example, so the answer for it is โˆ’1โˆ’1.

Alice, Bob, and Confucius are bored during recess, so they decide to play a new game. Each of them puts a dollar in the pot, and each tosses a coin. Alice wins if the coins land all heads or all tails. Bob wins if two heads and one tail land, and Confucius wins if one head and two tails land. The coins are fair, and the winner receives a net payment of $2 ($3 - $1 = $2), and the losers lose their $1.

A,B and C play a game and the chances of their winning it in an attempt are (2/3), (1/2) and (1/4) respectively. A has the first chance, followed by B and then by C. This cycle is repeated till one of them wins the game. Then the probability that B wins is*4/2116/218/211/21

In the last round of a chess tournament the final match is between Alice and Diego. The winner is the first player to win three games [sometimes called โ€œbest of 5โ€]. Assume that they are equally matched, so that each player has an equal probability of winning each game. What is the probability that the match will be finished after the first 3 games are played? 0.50 0.25 0.20 0.125

Two players, A and B.A goes first. They roll a dice that has random outputs between 1 and 30. The player who gets the higher number wins, and the loser pays the winner the amount that the winner gets on his dice.1. What is the expected winnings?2. Would you prefer being Player A or Player B? Why?

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.