#P2277. 24 Point Game Expression Count
24 Point Game Expression Count
24 Point Game Expression Count
The 24 Point Game is played by drawing 4 cards from a deck. The challenge is to combine the 4 given positive integers with the operators +
, -
, *
, /
and any necessary parentheses to form a valid expression that evaluates to \(24\). Two expressions are considered the same if their string representations (with full parenthesization) are identical. Given any 4 positive integers \(a, b, c, d\), count the number of distinct expressions that evaluate exactly to \(24\).
inputFormat
Four space-separated positive integers (a), (b), (c), (d).
outputFormat
An integer representing the count of distinct expressions that evaluate to (24).
sample
1 1 1 1
0