TopcoderARCHIVE
Archive/Problems/ThreeCardsDraw
SRM · Problem 17823

ThreeCardsDraw

Problem statement, definition, constraints, and public examples.

Problem Statement

You have a standard deck of playing cards, containing 52 cards in 4 suits and 13 values. The values are Ace (1), 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack (10), Queen (10), and King (10).

You are given int total. If you randomly select three cards--without replacement--from the deck, what is the probability their values will add up to total?

Definition

Class:
ThreeCardsDraw
Method:
totalChance
Parameters:
int
Returns:
double
Method signature:
double totalChance(int total)
(be sure your method is public)

Notes

  • Notes that aces have a value of 1, while jacks, queens and kings have a value of 10.

Constraints

  • total will be between 3 and 30, inclusive.

Examples

  1. 3
    Returns: 1.8099547511312217E-4
    The only way this can happen is to pick three of the four aces.
  2. 30
    Returns: 0.025339366515837104
  3. 5
    Returns: 0.0021719457013574662
    There's a few ways to select three cards and get a total of 5.
← All problems