Given L , R , G find the total elements in a set of range [L , R ] such that
The greatest positive integer which divides each element of the set is exactly G.
now simply the total elements would be (R / G) - (L-1) /G.
But there will be a case of a single element in set ie., if there is an only single element in the range then the value of G would be equal to that element.
For Ex ; L =4 , R =5 and G=2
the set in the range which divided by 2 is {4} only but no this is wrong, as the question says the The greatest positive integer which divides each element of the set is exactly G. so here for single element the greatest element which divides it is itself which is not equal to given G so the output would be 0.
So if the count of the element is 1 and G < L then answer will be 0
If u like this , my first editorial post please like and share.
Check Solution: CodeChef: Practical coding for everyone