/* Prime Number
Problem description
James is more interested in logarithm research. When talking about numbers, many problems have emerged in his mind. Today, James wants to test your understanding of prime numbers.
This is the problem: a decimal number, which is assumed to be a prime number. All its numbers and prime numbers are also called "prime number". For example, 29 is a prime number, and 2 + 9 = 11 is also a prime number, so it is a prime number.
Given a given interval, Can you calculate the number of elements in this interval?
Input
Enter a positive integer T in the first line, indicating that T groups of data (T <= 10000) are total ).
Next, there are t rows in total, and two integers L and R (1 <= L <= r <= 1000000) are entered in each row, indicating the left and right values of the range.
Output
For each group of data, the number of cases is output first, and then the number of elements in the output range (including the endpoint value L, R ).
Each group of data occupies one row. For details about the output format, see the example.
Sample Input
3
1 100
2 2
3 19
Sample output
Case #1: 14
Case #2: 1
Case #3: 4
*/
# Include <cstdio>
Int s [1000010] = {, 0 };
Int P [1000010];
Int main ()
{
Int A, B, T;
Int I, j, T;
Int m = 0, Kase;
For (I = 2; I * I <1000010; I ++)
{
If (! S [I])
{
For (j = 2 * I; j <1000010; j + = I)
S [J] = 1;
}
}
For (I = 2; I <1000010; I ++)
{
If (! S [I])
{
Int T = I, n = 0;
While (t)
{
N + = T % 10;
T/= 10 ;}
If (! S [N])
{M ++ ;}
}
P [I] = m;
}
Scanf ("% d", & T );
For (Kase = 1; Kase <= T; Kase ++)
{
Scanf ("% d", & A, & B );
Printf ("case # % d: % d \ n", Kase, P [B]-P [A-1]);
}
Return 0;
}