P301: Optimized all solutions with further math.