|
|
back to boardIdea To solve the problem, you can use the inclusion-exclusion principle. The intersection of two arithmetic progressions can be found by solving the Diophantine equation. If the difference in the new progression is too large, you can replace it with n+1. It should be noted that the first element of the new progression must be no less than the first elements of the intersecting progressions. You should also consider possible type overflows. My implementation uses int128, but I think it is possible to solve it using int64. Edited by author 15.07.2024 15:28 |
|
|