CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • All Contests
    • June Long 2012
    • May Cook-Off
    • May Long 2012
  • DISCUSS
    • Wiki
    • Forums
    • Blog
    • Facebook
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
    • Event Calendar
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » Indian Statistical Institute - CodeIT » Crazy Casino

Crazy Casino

Problem code: CIT02

  • All Submissions

In a gambling house, called Crazy Casino, there is a special slot machine before the exit. In this slot machine, there are SLOT many displays, each corresponds to one slot. In each slot, there are few coins with Happy mark and a single coin with Sad mark. On a hit, the machine independently chooses one element from each slot uniformly at random and displays them in the correponding screen. If the screen has all Sad marks, the player looses and he has to give up all his winnings. If all the marks are Happy, his earnings get doubled. Before playing this game the player is given iNEW many coins. Using each of these coins the player can increase the number of Happy marks in the slot of his choice. e.g. If the player puts three coins in slot 2, number of Happy marks in slot 2 gets increased by three. The player has to use all the iNEW coins before starting the game. Write a program to find out the minimum probability that a player looses against this machine. You will be given an int SLOT representing total number of slots, an int[] iList with initial number of coins (INCLUDING the Sad mark) in each slot and an int iNEW, total number of additional coins available. Your program should output p where 1/p is the minimum probability. You can assume SLOT < 100, iNEW< 100, iList[i]<100 for all i.

Input

The first input is the number of test cases (int) For each of the test cases the input numbers are arranged as follows:
SLOT, iList[], iNEW
Note that there is a comma (,) between SLOT and first element of iList. The elements of iList are separated by whitespace. Finally there is again a comma between the last element of iList and iNEW.

Output

The datatype of output should be double.

Example

Input:
A sample input sequence may look like the following

2
3, 5 7 2, 2
4, 3 3 3 3, 1
Output:
The corresponding output should be the following

140.00
108.00


Author: bst0602
Date Added: 9-01-2011
Time Limit: 1 sec
Source Limit: 50000 Bytes
Languages: C, CPP 4.0.0-8, CPP 4.3.2


  • Submit

Comments

  • Login or Register to post a comment.

The output format required is

manoharsingh23 @ 23 Jan 2011 01:32 PM

The output format required is of datatype double but here it is showing only 2 trailing 0's after 140 and 108. plz clarify.

the output format should be

aboltabol @ 23 Jan 2011 02:13 PM

the output format should be double.

is there a white space after

ishandutta2007 @ 23 Jan 2011 02:27 PM

is there a white space after the comma?

If format of output is double

manoharsingh23 @ 23 Jan 2011 02:48 PM

If format of output is double then it must be 140.000000 and 108.000000 . Why it is 140.00 && 108.00??

output must be an integer. i

pikku @ 23 Jan 2011 07:13 PM

output must be an integer. i dont know what the author tries to mean by "The datatype of output should be double"

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold
CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of computer programming. At CodeChef we work hard to revive the geek in you by hosting programming contests on a monthly basis. We also aim to have training sessions and events related to online programming for programmers around the world. Apart from providing a platform for programming competitions, CodeChef also has various tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our judge accepts solutions in over 35+ programming languages. Online programming was never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming competitions that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly programming contests and the shorter format Cook-off programming contests. Put yourself up for recognition and win great prizes. Prizes worth up to Rs.20,000 and $700 are up for grabs every month along with lots more CodeChef goodies.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be part of CodeChefs Forums and interact with all our programmers love helping out other programmers and share their ideas.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. Be a part of the CodeChef community through CodeChef meetups and techtalks. You can also host a programming contest for your institute on CodeChef and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com