P19218 [HackerRank] Megaprime numbers
普及
题目描述

A prime number is an integer greater than $1$ that has no positive divisors other than $1$ and itself.

We call a number megaprime if it is prime and all of its individual digits are prime. For example, $53$ is megaprime because it is prime and all its digits ($5$ and $3$) are prime; however, $35$ is not megaprime because it is not prime (it's divisible by $5$ and $7$), and $13$ is not megaprime because it has a non-prime digit ($1$ is not prime).

Given two long integers, $first$ and $last$, find and print the total number of megaprime numbers in the inclusive range between $first$ and $last$.

Input Format

Two space-separated long integers describing the respective values of $first$ and $last$.

Constraints

$1\leq first\leq last\leq10^{15}$
$last-first\leq10^9$

Output Format

Print a long integer denoting the total number of megaprimes in the inclusive interval between $first$ and $last$.

Sample Input 0
1 100

Sample Output 0
8

Explanation 0

There are eight megaprime numbers in the inclusive range from $first=1$ to $last=100$ (i.e., $2$, $3$, $5$, $7$, $23$, $37$, $53$, and $73$), so we print $8$ as our answer.

输入格式

见题面

输出格式

见题面

样例输入
1 100
样例输出
8