Count the Number of Ideal Arrays
HardLeetCodeCombinatorics & Modular Arithmetic
Approach hintTry it first, then revealHide
Fix the last element and factorise it: each prime's exponent rises in steps spread over the n positions, never decreasing. Stars and bars counts each prime independently, and the per-prime counts multiply.