HARSHAD  Devlali Numbers
Devlali numbers were an important coinage by Indian recreational mathemtician D. R. Kaprekar.
For any positive integer n, define d(n) as the sum of n and the digits of n. Eg, d(199) = 199 + 1 + 9 + 9 = 218.
For a positive number m, if there exists no positive number r such that d(r) = m, then m is a Devlali number. First few Devlali numbers are 1, 3, 5, 7, ... so on.
A prime number falling in this family is called a Devlali Prime. First few Devlali Primes are 3, 5, 7, ... so on.
Input
First line contains integer Q
Next Q lines contain two integers A and B
Output
print Q lines, each listing number of Devlali Primes in range [A,B] (both inclusive)
Limits
1 <= Q <= 100000
0 <= A <= B <= 1000000
Example
Input 3 1 3 0 10 5 8 Output 1 3 2
hide comments
below_average:
20210710 04:00:15
easy one..Ac in one go


deerawat:
20201228 13:12:08
Finally accepted after resolving test case 5 

neha93:
20201129 13:04:38
Easy one , my 100th :) 

vikas12:
20200419 23:02:08
i think i need more optmization 

akki098:
20200309 20:20:44
test case 5 is edge conditions


akki098:
20200309 12:51:59
test case 5 wrong?


shubhamptw:
20191010 23:13:17
In c++ using cout & cin gave tle but acc using printf & scanf 

nadstratosfer:
20180212 05:25:56
Good problem. Applied several ideas after the first AC, surprised to find out what worked here and what did not. Strangely, problem very much in style of the other Piyush Kumar, from Delhi. 

sahil_420420:
20160319 17:04:47
more testcases please with some big nmbers,testcase 5 wrong 

sarthak gupta:
20151023 10:40:25
good question....using stl the code length reduces to 1/4... :)

Added by:  Piyush Kumar 
Date:  20120921 
Time limit:  2.175s5.438s 
Source limit:  5000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All 