You are given a range (L, R). You are required to determine the prime rangers in this range. The definition of prime rangers is that the frequency of
the smallest prime digit must be greater than or equal to the frequency of the second-smallest prime digit in a number, the frequency of the second
smallest prime digit is greater than or equal to the frequency of the third-smallest prime digit in a number, and so on.
Note
9
The number of prime rangers may become very large. Therefore, print the prime rangers module 10^9 +7.
Input format
• The first line contains an integer T denoting the number of test cases
• Next T lines contain two space-separated integer L and R denoting the range in which you have to find the prime rangers.
Output format
Print the number of prime rangers modulo 10^9 +7.
Constraints
1<=T<=5
1<=L<=R< =10^18
Answers
Answered by
0
Answer:
Input : L = 1 and R = 20.
Output : 1
Prime number between 1 and 20 are 2, 3, 5, 7, 11, 13, 17, 19.
1 occur maximum i.e 5 times among 0 to 9.
Answered by
0
Answer:
Output Format:
Prime the numbers of prime rangers modulo 109+7
Constraints:
1<=T<=5
1<=L<=R<=1018
Sample Input
2
1 10
31 32
Sample Output
7
1
Explantation:
Test case 1 :
The number 3 5 and 7 are not prime rangers because in this numbers frequency of 2 is 0 but the frequency of the prime numbers is greater than 2 is 1.
Test case 2 :
The number 32 is prime ranger because the frequency of 2 is 1 and the frequency of 3 is 1 which satisfies the condition that the frequency of the smallest prime digit 2 is greater than equal to the frequency of the second smallest prime digit.
Explanation:
Similar questions