P2277 [HNOI2003] 24 Game

Description

To develop children's arithmetic skills, adults often have them play the following game: draw any $4$ cards from a deck of playing cards, and ask the child to use `+`, `-`, `*`, `/`, and parentheses to form a valid expression whose value is $24$. This game is called the "24 game". Given any four integers $a$, $b$, $c$, $d$, compute how many different expressions with value $24$ can be formed from these $4$ integers.

Input Format

The input contains one line with four integers $a$, $b$, $c$, $d$ ($0 \le a, b, c, d \le 100$).

Output Format

Output the number of expressions equal to $24$ that can be formed from $a$, $b$, $c$, $d$. If there are none, output $0$.

Explanation/Hint

Translated by ChatGPT 5