#P5950. [BalticOI 2000] Stickers
[BalticOI 2000] Stickers
Description
Charles bought a very large number of boxes of stickers from a shop. Each sticker has one digit from printed on it.
Each box contains the same number of stickers of each kind: stickers with digit , stickers with digit , …, stickers with digit . Also, in each box, the number of stickers of each digit does not exceed .
At the beginning, all boxes are closed. Each time, Charles opens one new box, and then takes the stickers he needs from the boxes that have already been opened to form a number: the first time he forms , the second time he forms , …, and the -th time he forms . To form the number , Charles needs to use one sticker for each digit in .
For example, after opening the -th box, in order to form the number , he needs to take one , two 's, and one from the already opened boxes (whether opened earlier or just now).
The stickers taken out can be used later. If after opening a box he cannot form the corresponding number, Charles stops working. Given , write a program to compute how many numbers Charles can form in total. For example, if each box contains exactly one sticker of each digit, then Charles can form numbers in total.
Input Format
The input contains one-digit integers: , where denotes the number of stickers with digit in each box.
Output Format
Output how many numbers can be formed.
3 4 5 4 3 4 5 4 3 4
49999999499999999949999999973
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号