P2347 [NOIP 1996 Senior] Weighing with Weights

Description

Given several weights of $1\mathrm{g}$, $2\mathrm{g}$, $3\mathrm{g}$, $5\mathrm{g}$, $10\mathrm{g}$, and $20\mathrm{g}$ (whose total weight is $\le 1000$), how many distinct total weights can be measured?

Input Format

Input: $a_1, a_2, a_3, a_4, a_5, a_6$. (This means there are $a_1$ weights of $1\mathrm{g}$, $a_2$ weights of $2\mathrm{g}$, $\dots$, and $a_6$ weights of $20\mathrm{g}$.)

Output Format

Output: `Total=N`. ($N$ is the number of distinct total weights that can be measured using these weights, excluding the case where no weight is used.)

Explanation/Hint

Source: NOIP 1996 Senior Problem 4. Translated by ChatGPT 5