#P16817. [蓝桥杯 2026 国 Python B] 稳定史莱姆
[蓝桥杯 2026 国 Python B] 稳定史莱姆
Problem Description
Xiao Lan raises slimes. The initial weight of the -th slime is .
It is known that a slime whose weight is not a multiple of is in a stable state, while a slime whose weight is a multiple of is in an unstable state. To make all slimes stable, Xiao Lan can cast a splitting spell.
Each time he casts the spell, Xiao Lan may choose a value that is divisible by . When the spell takes effect, all slimes whose current weight is exactly will split at the same time. Each such slime becomes three slimes of weight .
Now, please compute the minimum number of spells Xiao Lan needs to cast so that all slimes become stable.
Input Format
The first line contains an integer , representing the initial number of slimes.
The second line contains positive integers , representing the initial weights of the slimes.
Output Format
Output one integer, representing the minimum number of spell casts needed to make all slimes stable.
5
18 7 9 6 3
4
Hint
Sample Explanation
The initial weight sequence is: .
- Choose : the only in the sequence splits, and the sequence becomes .
- Choose : the only in the sequence splits, and the sequence becomes .
- Choose : now there are four 's in the sequence, and they all split at the same time into (reaching a stable state), and the sequence becomes .
- Choose : now all 's in the sequence split at the same time into (reaching a stable state).
After spells, none of the slimes' weights is divisible by , and all of them have reached a stable state.
Constraints
For of the testdata: , .
For all testdata: , .
Translated by ChatGPT 5