GONE - G-One Numbers

The War of Evil vs Good continues and Ra-One and G-One continue to be on respective sides.

After saving all the cities with Ra-One Numbers G-One realised that some cities whose population is a "G-One Number" can be easy target for Ra-One.

A G-One number is a number sum of whose digits is a prime number

For eg. 12 .. sum = 1+2 =3 ... 3 is a prime number.

G-One wants to find out all the populations which can be g-One numbers....

Can You help Him.?


You will be given the range of population and you have to tell him how many in this range are G-One Numbers.


first line has number 'c' indicating the number of ranges.

'c' lines follow and contain two numbers ..... 'f' and 't' inclusive.


Print a single line per case giving the number of populations which are G-One numbers.


10 19
1 9
20 29


Note: c will be less than 100
t and f will be less than 10^8 inclusive

hide comments
svader: 2020-06-25 06:54:58

Fine fn ally

jopdhiwaala: 2020-06-04 10:40:16

No one cares in how many attempts you did :)

kushagra_2: 2020-04-11 11:55:30

1st digit DP AC in one go :)

scolar_fuad: 2019-11-23 09:52:18

Easy digit dp problem
my 4th digit dp

gs0812: 2019-09-09 09:41:30

Down voted because too ez.

bhagirathi08: 2019-09-08 16:02:19

4th digit dp AC in one go

zingme123aptx: 2019-05-28 09:47:26

trâu cũng ac

hacker_sk: 2018-12-30 12:57:10

AC in two GO :P

sdssudhu: 2018-01-24 17:52:18

AC in one GO;)

pratham_1: 2017-09-07 15:59:56

AC in one GO;)

Added by:Devil D
Time limit:1s
Source limit:30000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64