QOJ.ac

QOJ

Time Limit: 3.0 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#9270. 深度素数

Statistics

对于任意非负整数 $x$,我们可以将其十进制表示视为一个由 $0$ 到 $9$ 组成的数字字符串。记该字符串为 $S(x)$。反之,对于任意由十进制数字组成的字符串 $s$,我们可以通过忽略所有前导零(除非该字符串仅表示整数 $0$)得到其代表的整数。记该整数为 $D(s)$。

我们称整数 $y$ 是整数 $x$ 的“整数子串”,如果存在一个字符串 $s$,它是 $S(x)$ 的子串(连续子序列),且满足 $D(s) = y$。

回想一下,如果一个正整数 $x$ 恰好有两个约数,则称其为质数。前五个质数是 $2, 3, 5, 7, 11$。

我们称整数 $x$ 为“深度质数”,如果 $x$ 本身是质数,且 $x$ 的任意整数子串 $y$ 也都是质数。

给定两个整数 $n$ 和 $m$,计算满足 $n \le x \le m$ 的深度质数 $x$ 的个数。

输入格式

输入仅一行,包含两个整数 $n$ 和 $m$ ($1 \le n \le m \le 10^{18}$)。

输出格式

输出一个整数,表示满足 $n \le x \le m$ 的深度质数 $x$ 的个数。

样例

样例输入 1

1 11

样例输出 1

4

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.