Recently I went to the Olympiad, and there was a task:
Three positive positive integers arrive at the input,
lraIt is necessary to find how many pairs of numbers fromltor(inclusive) can be composed, but the sum of these 2 numbers must be a multiple of the numberа.For example: 3 numbers 1 5 2 go to the input. Output 4 is possible. As you can make 4 pairs [1, 3] (1 + 3 = 4. 4 divided by 2 without remainder) [1,5] [2,4] [3,5].
If this problem is solved by enumeration, then for large numbers the program exceeds the time limit. I saw someone solve this problem mathematically, but I was ashamed to find out the details.