CodeChef: Codechef
Site under maintenance
  • Register
  • Forgot Password?
  • PRACTICE
    • Easy
    • Medium
    • Hard
  • COMPETE
    • August Mini Challenge
    • August Algorithm Challenge
    • July Algorithm Challenge
    • June Algorithm Challenge
    • May Gamers Challenge
  • DISCUSS
    • Forums
    • Blog
    • Twitter
  • COMMUNITY
    • CodeChef TechTalks
    • CodeChef Meetups
    • Campus Chapters
    • Host Your Contest
    • User Groups
  • HELP
    • Frequently Asked Questions
    • FAQ for Problem Setters
    • Tutorial: Paying Up
    • Tutorial: Small Factorials
    • Tutorial: Input and Output(I/O)
    • Tutorial: Your First Non-Trivial Problem
  • ABOUT
    • About CodeChef
    • About Directi
    • CEO's Corner
    • Press Room
    • Careers

Home » Problems (medium) » The Grand Cook Off

The Grand Cook Off

Problem code: COOKOFF2

  • Submit
  • All submissions

All submissions for this problem are available.

Chef is planning a grand cooking tournament for aspiring chefs in the region. The competition progresses with a number of one-on-one elimination rounds until only one chef remains. For each round, two chefs are chosen at random for a cook-off. The loser of the cook-off is elimited, while the winner moves on. Additionally, each chef begins with a positive number of prize tokens (some chefs begin with more than others, based on their performance in a qualification round). The winner of each cook-off receives all of the loser's prize tokens, and the loser is awarded a prize based on the number of prize tokens he/she had accrued.

The final cook-off always receives the most publicity. Your task it to compute the expected difference between the number of prize tokens of the final two competitors before the final cook-off. You will be given the number of tokens each chef begins with.

Input

Input begins with an integer T, the number of test cases (at most 50). Each test case consists of a single line, beginning with an integer C, the number of chefs in the competition, followed by C positive integers each describing the number of prize tokens a chef begins with. The total number of prize tokens among all chefs will be between 1 and 100, inclusive.

Output

For each test case, output the expected difference in prize tokens, rounded to 6 places after the decimal point.

Sample Input

3
3 1 1 1
3 1 1 2
4 10 10 10 30

Sample Output

1.000000
1.333333
26.666667


Date:2011-04-07
Time limit:1s
Source limit:50000B
Languages:All


  • Submit

Comments

Loading Comments...

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Loading Submissions...

RECENT ACTIVITY FOR THIS PROBLEM:

Loading Recent Activity...

HELP

Program should read from standard input and write to standard output.

After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:

  • Accepted Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark.
  • Time Limit Exceeded Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach.
  • Wrong Answer Your program compiled and ran succesfully but the output did not match the expected output.
  • Runtime Error Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section.
  • Compilation Error Your code was unable to compile. When you see this icon, click on it for more information.

If you are still having problems, see a sample solution here.

  • About CodeChef
  • About Directi
  • CEO's Corner
  • Careers
  • feedback@codechef.com

© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs

Sponsors
The time now is: