#P1149. [NOIP 2008 提高组] 火柴棒等式

[NOIP 2008 提高组] 火柴棒等式

Description

Given nn matchsticks, how many equations of the form A+B=CA+B=C can you make? In the equation, AA, BB, and CC are integers formed with matchsticks (if the number is nonzero, its most significant digit cannot be 00). The ways to form the digits 00 to 99 with matchsticks are shown in the figure:

Note:

  1. The plus sign and the equals sign each require two matchsticks.
  2. If ABA\neq B, then A+B=CA+B=C and B+A=CB+A=C are considered different equations (A,B,C0A,B,C\geq 0).
  3. All nn matchsticks must be used.

Input Format

A single integer nn (1n241 \leq n \leq 24).

Output Format

A single integer, the number of different equations that can be formed.

14
2
18
9

Hint

[Explanation for Sample 1]

The 22 equations are 0+1=10+1=1 and 1+0=11+0=1.

[Explanation for Sample 2]

The 99 equations are 0+4=40+4=4, 0+11=110+11=11, 1+10=111+10=11, 2+2=42+2=4, 2+7=92+7=9, 4+0=44+0=4, 7+2=97+2=9, 10+1=1110+1=11, 11+0=1111+0=11.

NOIP 2008 Senior Problem 2.

Translated by ChatGPT 5