#P1497. 木牛流马
木牛流马
Description
Kongming excitedly invited Pang Tong to visit. Intending to challenge him, Kongming placed Wooden Ox and Flowing Horse pieces on a large tiled grid and painted them in colors. He asked Pang Tong to count how many different valid layout configurations there are.
Input Format
First line: (, is the number of colors).
The next lines give the quantity of each color.
Output Format
The total number of valid layouts.
4 4 1
4
24
Hint
No big integer is needed. Moreover, Kongming stipulates that the grid cannot be flipped; that is, if two layouts become the same after a flip, they are still counted as two.
Translated by ChatGPT 5
京公网安备 11011102002149号