First, we notice that for all 2≤k≤2017, we always can find a partition satisfy i). For example, we can choose ai=2i−1, bi=2i with i=1,2,…,1009.
Denote m as the number of pairs (ai,bi) with ∣ai−bi∣=k then
T=(1009−m)⋅1+m⋅k=1009+(k−1)m.
Hence, the necessary condition of k is (k−1)m is divisible by 10. First, we can see that all numbers k≡1(mod5) satisfy the given condition.
Indeed, we have some cases:
1. If k≡1(mod10) then 10∣k−1 and ii) is satisfied.
2. If k≡6(mod10) then k is even. Thus, we need to prove m is even. This is true because we can write m=m1+m2 with m1,m2 are the number of pairs with the difference is k that have same parity and different parity. In X, the number of even and odd numbers are equal and all the pairs (ai,bi) with ∣ai−bi∣=1 also contain exactly 1 number in each type of even/odd. These imply that m1=m2 or m is an even number.
Hence, all numbers k≡1(mod5) satisfy the given condition.
Next, we will prove that all other numbers k do not satisfy the given condition.
3. If k is odd then k−1 is not divisible by 5. We choose the partition with a1=1, b1=k+1 and the rest are divided into pairs with ai,bi being two consecutive numbers. It is easy to check that this partition satisfies i) but not ii) because T=1008+k≡9(mod10).
4. If k is even, k−1 is not divisible by 5 then k−1 is an odd number that is not divisible by 5. We choose the partition with exactly two pairs (1,k+1),(2,k+2) and the rest are divided into pairs with ai,bi being two consecutive numbers. Similarly with the previous case, we have T=1009+2(k−1)≡9(mod10).
Therefore, the necessary and sufficient condition of k is k≡1(mod5). From 2 to 2017, we have 403 numbers in total satisfy it.