Magic Numbers
HardRating 2200CodeforcesAdvanced DP (Bitmask, Digit, Interval)
Approach hintTry it first, then revealHide
Run a digit DP over position, remainder modulo m and a tight flag: even positions are forced to be d, odd positions take any other digit. Since a and b have equal length, compute f(b) - f(a) and check a separately.