this is link of the question

https://www.codechef.com/HCS12019/problems/SETH0006/

what my approach is no of distinct numbers is much greater than number of non distinct numbers . so i am cheching for non distinct numbers in given range but problem is that

i am not getting how to get non distinct numbers greater than 1000 and less than given constraint range .