Modular Stability
HardRating 2000CodeforcesCombinatorics & Modular Arithmetic
Approach hintTry it first, then revealHide
An array is stable exactly when every element is a multiple of the smallest one. Fix the smallest value d and choose the other k - 1 elements among the larger multiples of d: sum C(n / d - 1, k - 1).