#P6522. [CEOI 2010] tower (day2)
[CEOI 2010] tower (day2)
Description
The tower has a total of levels, and each level consists of one cubic stone block with side length . A block can be placed directly on top of block if and only if , where is a given constant.
You need to find how many different building plans there are if all blocks are used. Output the result .
Note: Even if two blocks have the same side length, they are still considered different blocks.
Input Format
The first line contains two integers .
The second line contains integers , representing the side lengths of the cubic stone blocks.
Output Format
Output one line with one integer, the total number of plans .
4 1
1 2 3 100
4
6 9
10 20 20 10 10 20
36
Hint
Sample Explanation
Sample 1 Explanation
First, place the block with side length at the bottom. The remaining blocks can be placed in any order except for the following two cases: 2,1,3 and 1,3,2.
Sample 2 Explanation
First, it is not allowed to place on top of .
So, put all the blocks as a stack at the bottom, and all the blocks as a stack on the top.
That is .
Constraints
- For of the testdata, is guaranteed;
- For of the testdata, the number of plans does not exceed ;
- For of the testdata, is guaranteed;
- For of the testdata, is guaranteed;
- For of the testdata, , and all numbers in the input are positive integers not exceeding .
Notes
This problem is translated from CEOI 2010 day 2 T3 tower.
The translation copyright belongs to the problem provider
Translated by ChatGPT 5
京公网安备 11011102002149号