We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #121: Disc game prize fund

Project Euler #121: Disc game prize fund

Problem
Submissions
Leaderboard
Discussions

This problem is a programming version of Problem 121 from projecteuler.net

A bag contains one red disc and one blue disc. In a game of chance a player takes a disc at random and its colour is noted. After each turn the disc is returned to the bag, an extra red disc is added, and another disc is taken at random.

The player pays £1 to play and wins if they have taken more blue discs than red discs at the end of the game.

If the game is played for four turns, the probability of a player winning is exactly 11/120, and so the maximum prize fund the banker should allocate for winning in this game would be £10 before they would expect to incur a loss. Note that any payout will be a whole number of pounds and also includes the original £1 paid to play the game, so in the example given the player actually wins £9.

Find the maximum prize fund that should be allocated to a single game in which turns are played.

Input Format

The first line of input contains T, the number of test cases.

Each test case consists of a single line containing a single integer, .

Constraints


But for test cases worth half the total score, .

Output Format

For each test case, output a single line containing a single integer, the answer for that test case.

Sample Input

1
4

Sample Output

10

Explanation

The case correponds to the example given in the problem statement.

Author

kevinsogo

Difficulty

Easy

Max Score

100

Submitted By

518

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy