Before revision: For this problem, we can reduce 1000 operations to a few by using the inclusion–exclusion principle and a closed-form summation formula .
After revision: For this problem, we can reduce 1000 operations to a few by using the inclusion–exclusion principle and a closed-form summation formula