#P2000. The Summoning Arrays

    ID: 15282 Type: Default 1000ms 256MiB

The Summoning Arrays

The Summoning Arrays

In order to save the world, little a and uim decide to summon the deities kkksc03 and lzn. According to ancient scriptures, in order to summon any deity, you must arrange a specific formation (a "big array") using five elemental god stones: Metal, Wood, Water, Fire, and Earth. The scriptures record the following requirements:

Summoning kkksc03:

  • The number of Metal stones must be a multiple of \(6\).
  • At most \(9\) Wood stones can be used.
  • At most \(5\) Water stones can be used.
  • The number of Fire stones must be a multiple of \(4\).
  • At most \(7\) Earth stones can be used.

Summoning lzn:

  • The number of Metal stones must be a multiple of \(2\).
  • At most \(1\) Wood stone can be used.
  • The number of Water stones must be a multiple of \(8\).
  • The number of Fire stones must be a multiple of \(10\).
  • At most \(3\) Earth stones can be used.

On December 31, 1999, from 00:00:00 until 23:00:00, they failed to find any god stones. However, later at home, they discovered some mysterious chaos stones in their cellar. According to the ancient texts, these stones can be transformed into god stones by repeatedly striking them. In the end, at 23:59:59, they managed to produce exactly \(n\) god stones and completed the two formations.

To fully empower the deities, all possible formations using exactly \(n\) stones must be created. Compute the total number of possible ways to arrange the stones into the two required formations.

Note: Let the arrangement for kkksc03 be defined by five numbers \(J_1, M_1, S_1, F_1, T_1\) subject to:

  • \(J_1 \equiv 0 \pmod{6}\)
  • \(0 \le M_1 \le 9\)
  • \(0 \le S_1 \le 5\)
  • \(F_1 \equiv 0 \pmod{4}\)
  • \(0 \le T_1 \le 7\)

and the arrangement for lzn be defined by \(J_2, M_2, S_2, F_2, T_2\) subject to:

  • \(J_2 \equiv 0 \pmod{2}\)
  • \(0 \le M_2 \le 1\)
  • \(S_2 \equiv 0 \pmod{8}\)
  • \(F_2 \equiv 0 \pmod{10}\)
  • \(0 \le T_2 \le 3\)

The total number of stones used in both formations is exactly \(n\):

[ J_1 + M_1 + S_1 + F_1 + T_1 + J_2 + M_2 + S_2 + F_2 + T_2 = n. ]

After constructing the generating functions for the two formations, you will find that the total number of ways is given by the coefficient of \(x^n\) in \(\frac{1}{(1-x)^5}\). Hence, the answer is:

[ \binom{n+4}{4} = \frac{(n+1)(n+2)(n+3)(n+4)}{24}. ]

inputFormat

The input consists of a single integer \(n\) (\(n \ge 0\)), representing the total number of god stones available.

outputFormat

Output a single integer, the total number of ways to form the two arrays using all \(n\) stones.

sample

0
1