Given $N$ cards in poker and an integer $Q$. Choose several cards and form an expression, whose result equals to $Q$, via addition, subtraction, multiplication and division. Each expression, which meet the requirements, with $x$ cards can earn $x^2$ points. The intermediate value for each step must be an non-negative integer.
You need to calculate how many points you can get. Your attention, two expressions are different if and only if the prefix expressions of them are different. In others words, if an expression can transform to another through commutative law or associative law, these two expressions are considered distinct.
Moreover, two cards with the same number are also viewed different.