P2000 Saving the World
Background
In the year 2000, according to the prophecy of the seer Nostradamus, the world is about to be destroyed!!!
Description
To save the world, Xiao A and uim decide to summon the deities kkksc03 and lzn. According to ancient records, summoning any one deity requires arranging a specific grand formation using the Five-Element divine stones: Metal, Wood, Water, Fire, and Earth. The records state the following:
Summoning method for the deity 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 method for the deity 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.
It is December $31$, $1999$. Xiao A and uim started searching at $00{:}00{:}00$ and kept looking until $23{:}00{:}00$, but still could not find the divine stones.
However, after returning home, they discovered some strange items in their cellar. Consulting the ancient records—oh my, if only they had come earlier!—they found some chaos stones that can decay into the Five-Element divine stones by hammering. So they hammered frantically and finally obtained $n$ divine stones, completing two formations at $23{:}59{:}59$.
Indeed, the deities kkksc03 and lzn appeared, but due to insufficient energy, they could not exert their power. Only by setting up all formations that can be arranged using $n$ stones can they be fully charged. Xiao A and uim were dumbfounded and quickly contacted you to help calculate how many formations there are in total.
Input Format
Input a positive integer $n$.
Output Format
Output the number of formations that can be arranged using $n$ chaos stones.
Explanation/Hint
Constraints
For all testdata, $10^{99999}\leq n\lt 10^{100000}$.
Hint
Since it is already $23{:}59{:}59$, you have only $0.5$ seconds. (Xiao A and uim need $0.5\texttt s$ to lay out all formations.)
Translated by ChatGPT 5