#P10171. Distinct Remainders
Distinct Remainders
Distinct Remainders
Given a sequence \(\{a_n\}\) and an interval \([L,R]\), count how many integers \(k \in [L,R]\) satisfy that the remainders \(a_i \bmod k\) are all distinct. In other words, for each \(k\) you need to check if the set of remainders \(\{a_1 \bmod k, a_2 \bmod k, \dots, a_n \bmod k\}\) has exactly \(n\) unique elements.
inputFormat
The first line contains three integers: \(n\), \(L\) and \(R\) representing the number of elements in the sequence and the boundaries of the interval respectively.
The second line contains \(n\) space-separated integers \(a_1, a_2, \dots, a_n\).
outputFormat
Output a single integer: the count of \(k \in [L,R]\) such that the remainders \(a_i \bmod k\) (for \(1 \leq i \leq n\)) are all distinct.
sample
3 2 5
1 2 3
3